概述
文章目录
- 问题描述
- 解决方案
问题描述
tqdm针对jupyter notebook添加了专门的进度条方法tqdm_notebook()方法,调用语句如下:
from tqdm import tqdm,trange,tnrange,tqdm_notebook
from time import sleep
# 普通进度条
for i in trange(60):
#TODO:
sleep(.1)
# 专为notebook设计的进度条
for i in tqdm_notebook(range(600)):
#TODO:
sleep(.1)
但是tqdm_notebook在notebook没有显示进度条,并且打印了下面语句:
HBox(children=(IntProgress(value=0, max=822), HTML(value=’’)))
这个问题在github的issue:Jupyterlab and tqdm_notebook #394
解决方案
① 安装启动jupyter的控件拓展1:
pip install ipywidgets #或 conda install -c conda-forge ipywidgets
jupyter nbextension enable --py widgetsnbextension
② 安装相关库2:
conda install -c conda-forge nodejs
conda install yarn
如果没有安装过Node.js,可以去官方下载Node.js。
否则会报错:
An error occured.ValueError: Please install Node.js and npm before continuing installation. You may be able to install Node.js from your package manager, from conda, or directly from the Node.js website (https://nodejs.org).
See the log file for details: C:UsersADMINI~1AppDataLocalTempjupyterlab-debug-gorqzsue.log
③ 在JupyterLab中安装扩展3:
如果是JupyterLab 3.0以上版本:
conda install -n base -c conda-forge jupyterlab_widgets
如果是JupyterLab 1 或 2版本:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
查看你的JupyterLab版本:
jupyter lab --version
④ 查看已经安装成功的扩展:
jupyter labextension list
⑤ 此时,在jupyter lab中运行tqdm进度条,能够正常显示出来:
https://www.it1352.com/1846124.html ↩︎
https://blog.csdn.net/weixin_46088071/article/details/107712775 ↩︎
https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-in-jupyterlab-3-0 ↩︎
最后
以上就是冷静犀牛为你收集整理的解决JupyterLab中tqdm_notebook进度条不显示问题的全部内容,希望文章能够帮你解决解决JupyterLab中tqdm_notebook进度条不显示问题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复