ImportError: IProgress not found. Please update jupyter and ipywidgets although it is installed - pandas

I am using jupyter notebook and installed.
ipywidgets==7.4.2 widgetsnbextension pandas-profiling=='.0.0
and also I ran:
!jupyter nbextension enable --py widgetsnbextension
but when running:
from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)
profile.to_widgets()
I get the error:
ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
Any idea why?
Tried proposed solutions.

I tried everything you mentioned in a new environment using conda and I had another issue related to the version of ipywidgets (a bug found in Github with comments saying that got solved after using last version). I solved the problem I had installing last version of ipywidgets. Here is my process:
Create a new environment using conda (I use miniconda):
conda create --name teststackoverflow python=3.7
Activate new environment:
conda activate teststackoverflow
Install jupyter:
pip install jupyter
Install all the libraries without specific versions to get the last ones:
pip install ipywidgets widgetsnbextension pandas-profiling
Run jupyter notebook in the console to turn on the notebooks server and create a new notebook.
Run this line in a new cell:
!jupyter nbextension enable --py widgetsnbextension
With the result:
Enabling notebook extension jupyter-js-widgets/extension...
- Validating: OK
Run some sample code to define df:
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [1, 2, 3, 4]})
Run the code you provided:
from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)
profile.to_widgets()
Final output looks good:

this had worked for me (for all of you who prefer pip instead of conda..)
in your virtualenv run
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
or, if you prefer to run it in your notebook
!pip install ipywidgets
!jupyter nbextension enable --py widgetsnbextension
and in your notebook add
from ipywidgets import FloatProgress

Installing ipywidgets and building Jupyter Lab did the trick for me.
Make sure you activate the correct conda environment
Install ipywidgets: conda install -c conda-forge ipywidgets
To build Jupyter Lab, you need to have nodejs > 12.0.0 installed. Check the latest version number from Anaconda website and install nodejs specifying the package number e.g. conda install -c conda-forge nodejs=16.6.1
Stop Jupyter Lab
Build Juyter Lab: jupyter lab build
Start Jupyter Lab

I ran into the same error within the jupyter lab and I just installed ipywidgets using conda install -c conda-forge ipywidgets command.

I ran into the same error. On M1 mac, I change from tqdm.notebook import tqdm as tqdm to from tqdm import tqdm. Hope it helps. Original post: https://github.com/CosmiQ/solaris/issues/392#issuecomment-759238485

Related

Jupyter Notebook import not working after recent update

I recently used the following command to update my jupyter packages conda update --all and from then on my visualization libraries wont import(matplotlib and seaborn). I used conda install <pkg> even then it wouldnt. So I reinstalled anaconda3 but same problem persists...
I tried to view sys.executable and found that it was not referencing my python lib in anaconda but in python click here
'c:\\python38\\python.exe' So i used pip3 install matplotlib and matplotlib worked. I want my jupyter to reference to its own lib stack as I cannot install all libraries in python. I want the jupyter to read packages from this path : C:\Users\princ\anaconda3\Lib\site-packages because all anaconda libraries are there. How do I do it? Help me please. The problem is jupyter is referencing python package folder and not pre installed packages in anaconda
SYS.PATH:
'c:\\python38\\python38.zip',
'c:\\python38\\DLLs',
'c:\\python38\\lib',
'c:\\python38',
'',
'C:\\Users\\princ\\AppData\\Roaming\\Python\\Python38\\site-packages',
'c:\\python38\\lib\\site-packages',
'c:\\python38\\lib\\site-packages\\win32',
'c:\\python38\\lib\\site-packages\\win32\\lib',
'c:\\python38\\lib\\site-packages\\Pythonwin',
'c:\\python38\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\princ\\.ipython']
jupyter kernelspec list
python3 c:\python38\share\jupyter\kernels\python3
Did you tried running pip using directly the python executable with
python.exe -m pip install <pkg>
I don't know if there is a similar way to do it with conda

How to do interactive 2D scatter plot zoom / point selection in Vaex?

I saw that it is possible to do it during the demo: https://youtu.be/2Tt0i823-ec?t=769
There, the presenter has a huge dataset, and can quickly zoom in by selecting a rectangle with the mouse.
I also saw the "Interactive Widgets" section of the tutorial: https://docs.vaex.io/en/latest/tutorial.html#Interactive-widgets
However, I was not able to easily replicate that setup. What are the minimal steps to achieve it?
On Ubuntu 19.04 vaex 2.0.2, I have tried:
python3 -m pip install --user vaex scipy pandas vaex-jupyter
jupyter nbextension enable --py widgetsnbextension
jupyter nbextension enable --py bqplot
jupyter nbextension enable --py ipyvolume
jupyter nbextension enable --py ipympl
jupyter nbextension enable --py ipyleaflet
jupyter nbextension enable --py ipyvuetify
jupyter notebook
Then I created a notebook and paste in the notebook:
import vaex
import vaex.jupyter
import numpy as np
import pylab as plt
%matplotlib inline
df = vaex.example()
df.plot_widget(df.x, df.y, f='log1p', backend='bqplot')
but all I get is no graph and the message:
Plot2dDefault(w=None, what='count(*)', x='x', y='y', z=None)
If instead I do:
df.plot(df.x, df.y, f='log1p')
then I do get an plot, but it is just a non-interactive image.
I also tried to git clone the notebook that is the source of the read the docs page: https://github.com/vaexio/vaex/blob/0247f0673c5c0473001b0b66adcbc716560536aa/docs/source/tutorial.ipynb but the result was the same.
My motivation is to find a plotting program that can handle large number of points as mentioned at: Large plot: ~20 million samples, gigabytes of data
Use virtualenv
Not sure why, but this fixed it. I think it is because the Jupyter executable was on Python 2 and could not find Python 3 extensions.
virtualenv --python=python3 .venv
. .venv/bin/activate
python3 -m pip install vaex scipy pandas vaex-jupyter
jupyter nbextension enable --py widgetsnbextension
jupyter nbextension enable --py bqplot
jupyter nbextension enable --py ipyvolume
jupyter nbextension enable --py ipympl
jupyter nbextension enable --py ipyleaflet
jupyter nbextension enable --py ipyvuetify
jupyter notebook
and inside a new notebook:
import vaex
df = vaex.example()
df.plot_widget(df.x, df.y, f='log1p', backend='bqplot')
and now I see the interactive widget with zoom!
Versions:
pandas==0.25.0
scipy==1.3.0
vaex==2.0.2
vaex-jupyter==0.3.0
Jupyter widgets exist of front-end code and kernel code, the kernel code (Python in this case) is usually not the problem, if you can import for instance the ipywidgets module, you should be fine.
The biggest problem is making sure the front-end (classical notebook or Jupyter lab) has the matching javascript libraries loaded. Assuming you are working from the classical notebook, the way to debug is as following:
Since the javascript code of ipywidgets libraries are added to the frontend using the nbextension mechanism, you can check if all libraries are enabled and validated using
$ jupyter nbextension list
Which should show all green 'OK' and 'enabled' (unless you explicitly disabled it).
If not properly installed, you may want to do an installation of the front-end code, e.g.:
$ jupyter nbextension install --py --symlink --sys-prefix ipywidgets
$ jupyter nbextension install --py --symlink --sys-prefix ipyvuetify
If for some reason the extension is not automatically enabled (older versions of the notebook), run:
$ jupyter nbextension enable bqplot --py --sys-prefix
$ jupyter nbextension enable ipyvuetify --py --sys-prefix
If things aren't working, you should test which library isn't working, for instance, start with ipywidgets:
import ipywidgets as widgets
widget.FloatSlider()
If this doesn't show a slider, you are in trouble. Continue with the other libraries, and see when it fails. When it fails, check the javascript console (google that for your browser) for error messages, and see if you get hints from that.
Lastly, make sure you use a modern browser, Internet Explorer won't cut it anymore, it's too old. I recommend Chrome/Chromium or Firefox.

ModuleNotFoundError for pandas_datareader: Jupyter Notebook using different packages from conda environment

I am using Anaconda windows v5.3.
I am getting the error:
ModuleNotFoundError: No module named 'pandas_datareader'
When I tried to print out the packages used by Jupyter Notebook, I realized that pandas_datareader is not in, and a different version of pandas (0.23.0) is used:
import pkg_resources
for i in pkg_resources.working_set:
print(i)
Output
...
pandocfilters 1.4.2
pandas 0.23.0
packaging 17.1
openpyxl 2.5.3
...
This differs from the library installed in the pyfinance environment:
>conda list
# Name Version Build
pandas 0.20.3 py36_0
pandas-datareader 0.4.0 py36_0
Hence, pandas_datareader seem to work in the python shell in the command prompt, but not in jupyter notebook. Are there anyways to sync jupyter notebook environment to the conda environment?
I realized to sync jupyter notebook you just have to do:
conda install jupyter

cannot import selenium in new environment Anaconda python 3.6 even though it is installed

I created a new environment and installed some packages in Anaconda prompt:
conda create -n webscap requests scrapy lxml selenium html5lib pandas
activate webscap
conda config --env --add channels conda-forge
conda install -n webscap beautifulsoup4
I can see the selenium is installed by running !conda list -n webscap in jupyter:
selenium 3.9.0 py36_0 conda-forge
but when I import selenium I get:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-12-612ef00a7e75> in <module>()
----> 1 import selenium
ModuleNotFoundError: No module named 'selenium'
I even tried to install it again by conda install -n webscap selenium but got the same error again. Can anyone help please? Thanks!
In case anybody else has experienced the same problem, here is what worked for me:
It turned out that in the new environment I created webscap I was not able to import selenium in jupyter but I was able to do it in python prompt. This happened because the sys.path was different in jupyter from python prompt. In jupyter there was no path looking at the \\envs\\webscap\\, therefore I need to add the python sys.path to the jupyter sys.path like so:
import sys
sys.path
for element in r'C:\Users\<username>\Anaconda3\envs\webscap\python36.zip,C:\Users\<username>\Anaconda3\envs\webscap\DLLs,C:\Users\<username>\Anaconda3\envs\webscap\lib,C:\Users\<username>\Anaconda3\envs\webscap,C:\Users\<username>\Anaconda3\envs\webscap\lib\site-packages,C:\Users\<username>\Anaconda3\envs\webscap\lib\site-packages\win32,C:\Users\<username>\Anaconda3\envs\webscap\lib\site-packages\win32\lib,C:\Users\<username>\Anaconda3\envs\webscap\lib\site-packages\Pythonwin'.split(','):
sys.path.append(element)
Your code indicates that you created webscap instead of webscrap so you need to activate webscap:
conda create -n webscap requests scrapy lxml selenium html5lib pandas
activate webscap ## you created the env as webscap (not webscrap)
conda config --env --add channels conda-forge
conda install -n webscap beautifulsoup4

ipython cannot search matplotlib while using tensorflow and jupyter also has import error

I am using python 2.7 in Ubuntu and recently updated tensorflow 0.12.1.
I installed jupyter today for my sample code of tf and I need to use matplotlib. It does not find module name matplotlib and ipython in tensorflow has same error.
1. How can I set path in virtualenv or ipython or jupyter?
After activate tensorflow, I need to use jupyter notebook.
This below in the script for error does not work.
import sys
sys.path.append('my/path/to/module/folder')
import module-of-interest
2. other information: My environments are below.
mickyefromsd#DEKSTOP~$source ~/tensorflow/bin/activate
When I find matplotlib by python script under TF condition and before TF activation, it has below;
/usr/lib/python2.7/dist-packages/matplotlib/
When I type 'which ipython', it has below (not by /usr/bin/ipython) ;
/home/mickeyfromd/tensorflow/bin/ipython
Btw, /tensorflow/lib/python2.7/site-packages/ it has ipython and jupyter.
(not in the same path of matplotlib)
3. My ipython under TF cannot find my existing matplotlib.
(tensorflow) mickeyfromd#DK-DESKTOP:~$ ipython
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
In [1]: import matplotlib ImportError: No module named matplotlib
4. I wanted to setup virtualenv, so I just run this
I followed this site. site:http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs
(tensorflow) mickeyfromd#ipython kernelspec install-self --user
.....
Installed kernelspec python2 in /home/mickeyfromd/.local/share/jupyter/kernels/python2
(tensorflow) mickeyfromd#DK-DESKTOP:~$
I cannot move the the folder (in the second step)
How can I make ipython to have path for Matplotlib?
That import error is due to change in environment of the jupyter notebook. You might have installed the packages in one environment and you are running the jupyter notebook in another environment.
I have got two environments (envs) in my Anaconda folder ( I have Anaconda3 folder to be specific ).
(windows key+cmd ) -> open the windows command prompt run as administrator.
Activate (name of the environment) -> eg.: activate tensorflow-gpu
Start installing packages using conda install
Note: For each environment you need to install all the packages you want to use, separately using the same process. This solution is for windows users, might work for linux users not sure though.
Additionally to make sure your conda environment is up to date run:
conda update conda
conda update anaconda
check this out : https://pradyumnamajumder.wordpress.com/2017/09/30/solution-to-the-python-packages-import-error-in-jupyter/