Skip to content

tqdm.auto.tqdm problem detecting IPython (Spyder and Jupyter QtConsole) #1098

@AJJLagerweij

Description

@AJJLagerweij

Frontmatter

  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
    • documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand [StackOverflow#tqdm] is more appropriate)
    • new feature request
  • I have visited the [source website], and in particular
    read the [known issues]
  • I have searched through the [issue tracker] for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
    import tqdm, sys
    print(tqdm.__version__, sys.version, sys.platform)
    
    >>> 4.54.1 3.8.5 (default, Sep  4 2020, 07:30:14) 
    >>> [GCC 7.3.0] linux

Problem, Example

The tqdm.auto.tqdm tries to serve the nicely looking tqdm.notebook.tqdm class to my IPython console. The behaviour was tested using:

  • IPython 7.19.0
  • Spyder 4.2.0
  • Jupyter Console 6.2.0
  • Python 3.8.5
    all obtained through a conda installation.

The shortest code to recreate the problem is with the following script

# Import packages.
from tqdm.auto import tqdm
from time import sleep

# Keep track of sleep.
for _ in tqdm(range(6, 13)):
    sleep(1)

Which works from the terminal, using basic class tqdm.tqdm:
afbeelding

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

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 message HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=7.0), HTML(value=''))).
afbeelding
afbeelding

Background

I happened upon this issue when using the tqdm.contrib.concurrent.process_map function. I created an issuespyder-ide/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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions