简体   繁体   中英

Displaying progress bar using tqdm has error "Widget Javascript not detected…

I'm trying to display progress bar using tqdm. My system is windows 7 64-bits. Installing tqdm using conda install tqdm is not applicable. Therefore, I installed tqdm from https://anaconda.org/conda-forge/tqdm using a command in anaconda prompt as follows:

conda install -c conda-forge tqdm=4.8.4

I test it with the following example

from tqdm import tnrange, tqdm_notebook
from time import sleep

for i in tnrange(4,desc='1st loop'):
    for j in tnrange(10, desc='2nd loop'):
        sleep(0.01)

IPython console displays the following message:

Widget Javascript not detected.  It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"

May I know how to fix this problem? Thank you in advance.

The error happens because you can't evaluate things that were designed to run exclusively in the Jupyter notebook, in Spyder's IPython Console.

That's because they use frontends built with different technologies: the notebook with HTML, CSS and Javascript and the IPython console (which relies on the qtconsole package) with the Qt graphical toolkit.

This is an old error of IPython. You need to install the latest ipywidgets package (use conda) and maybe update Jupyter/IPython too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM