VS Code Interactive 未正确渲染 tqdm.notebook

j7s*_*kov 14 ipython visual-studio-code jupyter-notebook ipywidgets tqdm

我曾经在 VS Code Interactive 中使用过,我会得到如下tqdm.auto import tqdm的不错的输出:tqdm

tqdm.notebook 图像

我使用 venv 设置了一个新环境,但现在我失去了它 - 只有文本版本有效:

tqdm.auto import tqdm 仅适用于文本

当我运行这个示例单元时:

from tqdm.auto import tqdm
import time
for i in tqdm(range(10)):
    time.sleep(.1)
Run Code Online (Sandbox Code Playgroud)

我什么也没输出:

没有输出:(

我注意到 jupyter 日志中存在一些错误:

info 13:23:28.399: Execute Cell 2 Interactive-1.interactive
info 13:23:28.476: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:2.0.0
info 13:23:28.525: Widget Message: WidgetManager: Loading class ProgressStyleModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.526: Widget Message: WidgetManager: Loading class FloatProgressModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.527: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:2.0.0
info 13:23:28.527: Widget Message: WidgetManager: Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.527: Widget Message: WidgetManager: failed, Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.527: Widget Message: WidgetManager: failed, Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
error 13:23:28.532: Widget load failure {} {
  className: 'HTMLStyleModel',
  moduleName: '@jupyter-widgets/controls',
  moduleVersion: '2.0.0',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 13:23:28.534: Widget Message: WidgetManager: Loading class HTMLModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.534: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:2.0.0
info 13:23:28.534: Widget Message: WidgetManager: Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.534: Widget Message: WidgetManager: failed, Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.534: Widget Message: WidgetManager: failed, Loading class HTMLStyleModel:@jupyter-widgets/controls:2.0.0
error 13:23:28.534: Widget load failure {} {
  className: 'HTMLStyleModel',
  moduleName: '@jupyter-widgets/controls',
  moduleVersion: '2.0.0',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 13:23:28.535: Widget Message: WidgetManager: Loading class HTMLModel:@jupyter-widgets/controls:2.0.0
info 13:23:28.536: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:2.0.0
info 13:23:28.542: Widget Message: WidgetManager: Loading class HBoxModel:@jupyter-widgets/controls:2.0.0
info 13:23:29.464: Cell 2 executed with state Success
Run Code Online (Sandbox Code Playgroud)

小智 20

我认为你的假设是正确的。我将 ipywidgets 降级到 7.7.1 后,tqdm.notebook 工作正常。

  • 确认这确实是一种解决方案。 (3认同)
  • 谢谢。我还在 venv 中使用“pip uninstall ipywidgets”然后“pip install ipywidgets==7.7.2”进行了测试。这对我也有用。 (2认同)