Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tqdm_notebook fails with IPython 3 #187

Closed
QuLogic opened this issue Jun 23, 2016 · 23 comments
Closed

tqdm_notebook fails with IPython 3 #187

QuLogic opened this issue Jun 23, 2016 · 23 comments
Assignees
Labels
p0-bug-critical ☢ Exception rasing

Comments

@QuLogic
Copy link

QuLogic commented Jun 23, 2016

Running something simple like:

import tqdm
for i in tqdm.tqdm_notebook(range(1000000)):
    i * 2

produces this traceback:

NameError                                 Traceback (most recent call last)
<ipython-input-6-207cef0f8cd2> in <module>()
      1 import tqdm
----> 2 for i in tqdm.tqdm_notebook(range(1000000)):
      3     i * 2

~/.local/lib/python3.4/site-packages/tqdm/__init__.py in tqdm_notebook(*args, **kwargs)
     17     """See tqdm._tqdm_notebook.tqdm_notebook for full documentation"""
     18     from ._tqdm_notebook import tqdm_notebook as _tqdm_notebook
---> 19     return _tqdm_notebook(*args, **kwargs)
     20 
     21 

~/.local/lib/python3.4/site-packages/tqdm/_tqdm_notebook.py in __init__(self, *args, **kwargs)
    182         # self.sp('', close=True)
    183         # Replace with IPython progress bar display (with correct total)
--> 184         self.sp = self.status_printer(self.fp, self.total, self.desc)
    185         self.desc = None  # trick to place description before the bar
    186 

~/.local/lib/python3.4/site-packages/tqdm/_tqdm_notebook.py in status_printer(file, total, desc)
    103         # Prepare IPython progress bar
    104         if total:
--> 105             pbar = IntProgress(min=0, max=total)
    106         else:  # No total? Show info style bar with no progress tqdm status
    107             pbar = IntProgress(min=0, max=1)

NameError: name 'IntProgress' is not defined

using 4.7.4-a581bbd.

The conditional imports seem a bit confused about versions. The comments in the first block say ipywidgets is IPython 4.x, and IPython.html.widgets is 3.x/2.x, but the second block always imports from ipywidgets.

@lrq3000 lrq3000 added the p0-bug-critical ☢ Exception rasing label Jun 24, 2016
@lrq3000 lrq3000 self-assigned this Jun 24, 2016
@lrq3000
Copy link
Member

lrq3000 commented Jun 24, 2016

I'll check it out, thank you for reporting the bug. About the import of ipywidgets, it's normal, it's because all imports are aliased to ipywidgets to uniformize the lines of codes importing the widgets after.

@QuLogic
Copy link
Author

QuLogic commented Jun 24, 2016

Aliasing does not appear to apply to imports in either Python version:

python
Python 2.7.11 (default, Mar 31 2016, 20:46:51) 
[GCC 5.3.1 20151207 (Red Hat 5.3.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml as lx
>>> from lx import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named lx
>>> import lxml.etreepython3
Python 3.4.3 (default, Mar 31 2016, 20:42:37) 
[GCC 5.3.1 20151207 (Red Hat 5.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml as lx
>>> from lx import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'lx'
>>> import lxml.etree

@casperdcl
Copy link
Sponsor Member

that's interesting. Nobody reported issues when I added this. grrr...

@lrq3000
Copy link
Member

lrq3000 commented Jul 3, 2016

@casperdcl oops sorry no, mea culpa. I tried with IPython v4 (which works because there's no aliasing), but I didn't try with other versions as I was convinced import aliasing would work in Python.

@casperdcl
Copy link
Sponsor Member

merged in #190 - though python needs to make up its mind about warnings...

@casperdcl
Copy link
Sponsor Member

@philipsd6 I received a notification that you commented here but I can't seem to find your comment. Did you delete it?

@philipsd6
Copy link

Yup, I was being dumb, so I erased the evidence.

@casperdcl
Copy link
Sponsor Member

Oh, ok, great! Feel free @philipsd6 and @QuLogic to 👍 this comment!

@lrq3000
Copy link
Member

lrq3000 commented Oct 22, 2016

Ah good, because I was already looking on how to fix the issue XD

@philipsd6
Copy link

Just for reference, I have a notebook that creates Jupyter kernels by setting up a new virtualenv, installing ipykernel, and creating the kernel file. All I was missing was to also install ipywidgets in the venv. See? Dumb. ;)

@stefanv
Copy link

stefanv commented Mar 1, 2017

@philipsd6 The error message when ipywidgets is missing is pretty obscure :/ NameError: name 'IntProgress' is not defined <-- Not a great hint where to look.

@b3by
Copy link

b3by commented Mar 22, 2017

The error seems to still be there with iPython5!

@balarsen
Copy link

I certainly get this error still

Software Version
Python 3.6.1 64bit [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
IPython 5.3.0
OS Darwin 15.6.0 x86_64 i386 64bit
matplotlib 2.0.0
numpy 1.11.3
xarray 0.9.1
tqdm 4.11.2
Fri Mar 31 16:47:45 2017 MDT

@vignesh-m
Copy link

The short answer is to install ipywidgets

@stevenmanton
Copy link

I'm having the same issue. Installing ipywidgets didn't fix it, unfortunately.

@caidish
Copy link

caidish commented Apr 12, 2017

I'm having the same issue.In my windows desktop,it works well.However,when I run the same code on Ubuntu,it breaks down.

@davidsmandrade
Copy link

I've installed ipywidgets too and it not working yet. Obs: I'm running on ubuntu. Thanks!

@andrewzwicky
Copy link

andrewzwicky commented Apr 24, 2017

I tried this and got it to work for me, not sure if this will help anyone else or not.

jupyter-widgets/ipywidgets#541

jupyter nbextension enable --py --sys-prefix widgetsnbextension

Using (irrelevant packages omitted):
ipykernel==4.6.1
ipyparallel==6.0.2
ipython==6.0.0
ipython-genutils==0.2.0
ipywidgets==6.0.0
jupyter-client==5.0.1
jupyter-core==4.3.0
nbconvert==5.1.1
nbformat==4.3.0
notebook==5.0.0
tqdm==4.11.2
widgetsnbextension==2.0.0

@caidish
Copy link

caidish commented Apr 26, 2017

@andrewzwicky Thanks a lot!It really helps.jupyter nbextension enable --py --sys-prefix widgetsnbextension

@stolsvik
Copy link

Not really sure if this helped or not, but after dozens of attempts, I ran both "install" and "enable". It worked afterwards. One should think the enable performed install, but the output of the two commands was at least different. (Do note that this wasn't exactly a scientific experiment, as I probably had changed dozens of parameters of the system by that time..!)

Anyway: jupyter nbextension install --py --sys-prefix widgetsnbextension

@rodrigoruiz
Copy link

I'm still having the same issue when running on Google Colab.

@chengs
Copy link
Contributor

chengs commented Jul 5, 2018

@rodrigoruiz ipywidget is not supported by Google Colab. googlecolab/colabtools#60

@jcorro2
Copy link

jcorro2 commented Nov 28, 2018

I did this to make it work:

conda install -c conda-forge ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install @jupyter-widgets/jupyterlab-manager
conda install jupyter

The last command is likely to kill your running kernel. If you are training or just trained a large model, I'd suggest you save it to disk before running the last command so you can recover from where you left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p0-bug-critical ☢ Exception rasing
Projects
None yet
Development

No branches or pull requests