ImportError: IProgress not found. Please update jupyter and ipywidgets although it is installed

ImportError: IProgress not found. Please update jupyter and ipywidgets although it is installed

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

ipywidgets==7.4.2 widgetsnbextension pandas-profiling=='.0.0

还有我运行:

!jupyter nbextension enable --py widgetsnbextension

但是当runninhg

from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)
profile.to_widgets()

我收到错误:

ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html

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

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

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

结果:

Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
  1. 运行 一些示例代码来定义 df:
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [1, 2, 3, 4]})
  1. 运行您提供的代码:
from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)
profile.to_widgets()

最终输出看起来不错:

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

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

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

!pip install ipywidgets
!jupyter nbextension enable --py widgetsnbextension

并在你的笔记本中添加

from ipywidgets import FloatProgress

安装 ipywidgets 和构建 Jupyter Lab 对我有用。

  1. 确保激活正确的 conda 环境
  2. 安装ipywidgets:conda install -c conda-forge ipywidgets
  3. 要构建 Jupyter Lab,您需要安装 nodejs > 12.0.0。从 Anaconda website 检查最新版本号并安装指定包号的 nodejs,例如conda install -c conda-forge nodejs=16.6.1
  4. 停止 Jupyter Lab
  5. 构建 Juyter 实验室:jupyter lab build
  6. 启动 Jupyter 实验室

我 运行 在 jupyter 实验室中遇到了同样的错误,我刚刚使用 conda install -c conda-forge ipywidgets 命令安装了 ipywidgets。