python - tqdm 不计算 jupyter notebook 中的迭代次数
问题描述
我tqdm
用来显示迭代的进度。jupyter notebook
但是它在我的环境中无法正常工作。
我可以
from tqdm import tqdm
a = 0
for i in tqdm(range(10)):
a += i
print(a)
带输出
然而,这print
对循环中的语句有问题(请参见此处)。当我做
from tqdm.notebook import tqdm
a = 0
for i in tqdm(range(10)):
a += i
print(a)
我明白了
即迭代被执行,但 tqdm 不考虑它们。
知道如何解决这个问题或问题可能是什么?
的输出jupyter --version
是
jupyter core : 4.7.1
jupyter-notebook : 6.2.0
qtconsole : not installed
ipython : 7.20.0
ipykernel : 5.1.0
jupyter client : 6.1.11
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : 7.6.3
nbformat : 5.1.2
traitlets : 5.0.5
编辑 这个问题似乎与 MacOS 相关(我运行的是 10.15.7),因为我没有在 CentOS 上观察到它。
除此之外,我尝试了更新我的 conda 环境
jupyter core : 4.7.1
jupyter-notebook : 6.2.0
qtconsole : 5.0.2
ipython : 7.20.0
ipykernel : 5.5.0
jupyter client : 6.1.11
jupyter lab : not installed
nbconvert : 6.0.7
ipywidgets : 7.6.3
nbformat : 5.1.2
traitlets : 5.0.5
在 python 3.8.8 上。(我也在 3.7.10 上试过)。
这个问题讨论了类似的问题,问题似乎与ipywidgets
.
解决方案
我在 Jupyter Lab (3.0.9) 中遇到了同样的问题,这对我有用:
jupyter labextension install @jupyter-widgets/jupyterlab-manager \
&& jupyter lab
即使ipywidgets
应该自动安装 labextension,它也没有在jupyter labextension list
. 当我手动安装它时,进度条工作。
对于经典笔记本,ipywidgets
文档提到了这一点:
jupyter nbextension enable --py widgetsnbextension
推荐阅读
- excel - 下载带有主题的 Outlook 附件
- javascript - 填写用户名和姓氏并转到下一页
- javascript - 订阅返回未定义的变量
- firebase - Java.Lang.NullPointerException:尝试调用虚拟方法'void com.google.firebase.auth.FirebaseAuth.zza
- r - 在长格式中找到不同的因子值
- sql - 如何在加入/下推到外部服务器之前强制评估子查询
- react-native - 如何为每个屏幕多堆栈导航创建自定义标题选项反应原生?
- python - 如何声明一个目标函数(最小化)及其对 Python 的上限和下限的约束?
- python - 标记保留在引号内的字符串
- identityserver4 - 接收错误:方法“FindIdentityResourcesByScopeNameAsync”没有实现