我是靠谱客的博主 冷静犀牛,最近开发中收集的这篇文章主要介绍解决JupyterLab中tqdm_notebook进度条不显示问题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

文章目录

    • 问题描述
    • 解决方案

问题描述

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进度条,能够正常显示出来:
在这里插入图片描述


  1. https://www.it1352.com/1846124.html ↩︎

  2. https://blog.csdn.net/weixin_46088071/article/details/107712775 ↩︎

  3. https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-in-jupyterlab-3-0 ↩︎

最后

以上就是冷静犀牛为你收集整理的解决JupyterLab中tqdm_notebook进度条不显示问题的全部内容,希望文章能够帮你解决解决JupyterLab中tqdm_notebook进度条不显示问题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(87)

评论列表共有 0 条评论

立即
投稿
返回
顶部