Skip to content

tqdm_notebook erroring out since 4.16.0 #441

@adamhadani

Description

@adamhadani

Hey,
I came across an issue while using tqdm_notebook(total=123, desc="my description") in a Jupyter notebook. I'm running into the following error. This only happens beginning with version 4.16.0 (4.15.0 seems to work):

~/.virtualenvs/venv/lib/python3.6/site-packages/tqdm/_tqdm_notebook.py in __init__(self, *args, **kwargs)
    186         # Print initial bar state
    187         if not self.disable:
--> 188             self.sp(self.__repr__())  # same as self.refresh without clearing
    189 
    190     def __iter__(self, *args, **kwargs):

~/.virtualenvs/venv/lib/python3.6/site-packages/tqdm/_tqdm.py in __repr__(self)
    839             self.unit, self.unit_scale,
    840             1 / self.avg_time if self.avg_time else None,
--> 841             self.bar_format, self.postfix)
    842 
    843     def __lt__(self, other):
~/.virtualenvs/venv/lib/python3.6/site-packages/tqdm/_tqdm.py in format_meter(n, total, elapsed, ncols, prefix, ascii, unit, unit_scale, rate, bar_format, postfix, unit_divisor)
    307 
    308             # format the stats displayed to the left and right sides of the bar
--> 309             bool_prefix_colon_already = (prefix[-2:] == ": ") # old prefix setup work around
    310             if prefix:
    311               l_bar = prefix if bool_prefix_colon_already else prefix + ": "

TypeError: 'NoneType' object is not subscriptable

I started tracing through this and saw that in _tqdm_notebook.py around line 184 (as of version 4.17.0) we set self.desc to none before calling self.__repr__:

        self.desc = None  # trick to place description before the bar

        # Print initial bar state
        if not self.disable:
            self.sp(self.__repr__())  # same as self.refresh without clearing

Seems related but I'm not sure what would be the right fix since the logic seems fairly involved.

I'm running:
Python 3.6.1
Jupyter 4.3.0
tqdm 4.17.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions