导入错误:找不到 IProgress。尽管已安装,但请更新 jupyter 和 ipywidgets

oku*_*oub 50 pandas jupyter jupyter-notebook ipywidgets pandas-profiling

我正在使用 jupyter 笔记本并安装。

ipywidgets==7.4.2 widgetsnbextension pandas-profiling=='.0.0
Run Code Online (Sandbox Code Playgroud)

我也跑了:

!jupyter nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)

但运行时:

from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)
profile.to_widgets()
Run Code Online (Sandbox Code Playgroud)

我收到错误:

ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
Run Code Online (Sandbox Code Playgroud)

知道为什么吗?尝试了建议的解决方案。

小智 53

我在新环境中尝试了你提到的所有内容,conda并且遇到了另一个与版本相关的问题ipywidgets(在 Github 中发现的一个错误,评论说使用上一个版本后已解决)。我解决了安装最新版本的ipywidgets. 这是我的过程:

  1. conda使用(我使用 miniconda)创建一个新环境:
conda create --name teststackoverflow python=3.7
Run Code Online (Sandbox Code Playgroud)
  1. 激活新环境:
conda activate teststackoverflow
Run Code Online (Sandbox Code Playgroud)
  1. 安装jupyter
pip install jupyter
Run Code Online (Sandbox Code Playgroud)
  1. 安装所有没有特定版本的库以获取最新版本:
pip install ipywidgets widgetsnbextension pandas-profiling
Run Code Online (Sandbox Code Playgroud)
  1. jupyter notebook在控制台中运行以打开笔记本服务器并创建一个新笔记本。
  2. 在新单元格中运行此行:
!jupyter nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)

结果:

Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
Run Code Online (Sandbox Code Playgroud)
  1. 运行一些示例代码来定义df
conda create --name teststackoverflow python=3.7
Run Code Online (Sandbox Code Playgroud)
  1. 运行您提供的代码:
conda activate teststackoverflow
Run Code Online (Sandbox Code Playgroud)

最终输出看起来不错: 运行步骤 8 的最终结果


Avi*_*dan 27

这在你的 virtualenv 运行中对我有用(对于所有喜欢 pip 而不是 conda 的人..)

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)

或者,如果您喜欢在笔记本中运行它

!pip install ipywidgets
!jupyter nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)

并在你的笔记本中添加

from ipywidgets import FloatProgress
Run Code Online (Sandbox Code Playgroud)