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

问题描述 投票:0回答:6

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

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

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

pandas jupyter-notebook jupyter ipywidgets pandas-profiling
6个回答
53
投票

我在新环境中使用

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()

最终输出看起来不错:


27
投票

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

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

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

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

并在你的笔记本中添加

from ipywidgets import FloatProgress

4
投票

安装 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 实验室

3
投票

我遇到了同样的错误。在 M1 mac 上,我将

from tqdm.notebook import tqdm as tqdm
更改为
from tqdm import tqdm
。希望能帮助到你。原帖:https://github.com/CosmiQ/solaris/issues/392#issuecomment-759238485


2
投票

我在 jupyter 实验室中遇到了同样的错误,我刚刚使用

conda install -c conda-forge ipywidgets
命令安装了 ipywidgets。


0
投票

此错误已在 jupyter 的最新更新中修复。请在终端中运行此命令

pip install --upgrade jupyter

© www.soinside.com 2019 - 2024. All rights reserved.