8

我正在使用 jupyter notebook 并安装

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

我也跑了:

!jupyter nbextension enable --py widgetsnbextension

但是当运行时

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

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

4

4 回答 4

14

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

  1. conda使用(我使用 miniconda)创建一个新环境:
conda create --name teststackoverflow python=3.7
  1. 激活新环境:
conda activate teststackoverflow
  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()

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

于 2021-06-21T19:32:01.800 回答
4

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

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

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

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

并在您的笔记本中添加

from ipywidgets import FloatProgress
于 2021-07-07T08:18:13.187 回答
2

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

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

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

于 2021-12-01T12:14:52.140 回答