-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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.auto.tqdm problem detecting IPython (Spyder and Jupyter QtConsole) #1098
Comments
As pointed out in jupyter/qtconsole#461 (comment) and in the FAQs (try using
Yup this annoyance. Will see about sending both representations... |
Yes, when running
Whereas the documentation of tqdm.auto indicates that it does suppress this warning if it selects It is quite clear what happens when calling these two functions, ( Lastly I want to propose a quick and dirty fix, but I'm unsure whether this is possible in python. I would like a warning to be printed with an explanation regarding |
actually I think this issue is also essentially a duplicate of #937, #1035 (i.e. same solution - support both HTML & text rendering). I never managed to fix it because of jupyter-widgets/ipywidgets#2850 but maybe things have changed and someone can open a PR? |
because 99.9% of users wanting to auto-detect Notebook & CLI ( |
can you try |
I've tried the dev version, and see the appropriate progress bar appear using import tqdm
print(tqdm.__version__)
>>> 4.54.2.dev6+g5b9961f
# Import and run basic tqdm version
from tqdm import tqdm
from time import sleep
# Track sleep.
for _ in tqdm(range(6, 13)):
sleep(1)
>>> 100%|██████████| 7/7 [00:07<00:00, 1.00s/it]
# Import and run automatic tqdm version
from tqdm.auto import tqdm
from time import sleep
# Track sleep.
for _ in tqdm(range(6, 13)):
sleep(1)
>>> 0%| | 0/7 [00:00<?, ?it/s]
TqdmDeprecationWarning: Please use `tqdm.gui.tqdm(...)` instead of `tqdm(..., gui=True)`
---------------------------------------------------------------------------
TqdmDeprecationWarning Traceback (most recent call last)
<ipython-input-3-6d59c09eeffd> in <module>
3
4 # Track sleep.
----> 5 for _ in tqdm(range(6, 13)):
6 sleep(1)
7
~/.anaconda3/envs/tqdm/lib/python3.8/site-packages/tqdm/notebook.py in __iter__(self, *args, **kwargs)
258 def __iter__(self, *args, **kwargs):
259 try:
--> 260 for obj in super(tqdm_notebook, self).__iter__(*args, **kwargs):
261 # return super(tqdm...) will not catch exception
262 yield obj
~/.anaconda3/envs/tqdm/lib/python3.8/site-packages/tqdm/std.py in __iter__(self)
1147
1148 if getattr(self, 'sp', None) is None:
-> 1149 raise TqdmDeprecationWarning(
1150 "Please use `tqdm.gui.tqdm(...)` instead of"
1151 " `tqdm(..., gui=True)`\n",
TqdmDeprecationWarning: Please use `tqdm.gui.tqdm(...)` instead of `tqdm(..., gui=True)` While the
|
@AJJLagerweij ah yes ofc, can you try again now? In |
Wow, thanks, it seems to work as you expect. # Import packages.
import tqdm
print(tqdm.__version__)
>>> 4.54.2.dev8+ge225d9a
# Import tqdm.auto.
from tqdm.auto import tqdm
from time import sleep
# Track sleep.
for _ in tqdm(range(6, 13)):
sleep(1)
>>> 0%| | 0/7 [00:00<?, ?it/s] No crashes or errors and as you mention it stays at 0% till the end. You mention that there is no way to force updating in a Jupyter console. I'll ask them if we can do something about that, but before that I would like to understand the issue. After all the normal |
Specifically, no way to force update a widget afaik. You can always use plain The issue is |
Thanks that it is clear, I'll communicate that with the Jupyter community. Let's see if they can implement that. |
Should this be closed? With latest versions I see the same stuck at zero percent. I also still get these errors in the console I think the way the comms work is that there is a per-frontend extension that manages setting them up. So you can send still send updates but they just run into a wall on the frontend. Probably the best way to will be to detect if the comm is actually set up properly and then remove the widget from the mimebundle and update the display however you do in ipython. Though I don't see an obvious way to detect this :/ (I will ask around about this) |
Part of that asking is here: https://gitter.im/jupyter-widgets/Lobby?at=602c8e2c93539e23437de478 |
@ianhi this is closed simply because it seems to be an upstream issue which |
Frontmatter
read the [known issues]
environment, where applicable:
Problem, Example
The
tqdm.auto.tqdm
tries to serve the nicely lookingtqdm.notebook.tqdm
class to my IPython console. The behaviour was tested using:all obtained through a conda installation.
The shortest code to recreate the problem is with the following script
Which works from the terminal, using basic class

tqdm.tqdm
:Works from Jupyter Notebook using the decorated class

tqdm.notebook.tqdm
:Fails in IPython, via Jupyter Console, Jupyter QtConsole and Spyder. It tries to serve the


tqdm.notebook.tqdm
class while this cannot be displayed properly. Resulting in the following messageHBox(children=(HTML(value=''), FloatProgress(value=0.0, max=7.0), HTML(value='')))
.Background
I happened upon this issue when using the
tqdm.contrib.concurrent.process_map
function. I created anissue
jupyter/qtconsole#461 on the Jupyter QtConsole git, which after a short discussion pointed out the solution for my specific case. I was also pointed out the difficulties of detecting the frontend and possible ways to solve that.Because the solution was including the optional key
tqdm_class
,see the documentation, it became apparent that there is an issue in the
tqdm.auto.tqdm
class.Related Issues
The following issues are related, but far older and closed: #747, #645, #394.
The text was updated successfully, but these errors were encountered: