【问题标题】:ImportError: IProgress not found. Please update jupyter and ipywidgets although it is installedImportError:未找到 IProgress。请更新 jupyter 和 ipywidgets 虽然它已安装
【发布时间】:2021-09-01 00:13:02
【问题描述】:

我正在使用 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

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

【问题讨论】:

    标签: pandas jupyter-notebook jupyter ipywidgets pandas-profiling


    【解决方案1】:

    我在使用conda 的新环境中尝试了您提到的所有内容,但我遇到了与ipywidgets 版本相关的另一个问题(在 Github 中发现的一个错误,cmets 说使用上一个版本后得到了解决)。我解决了安装最新版本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()
    

    最终输出看起来不错:

    【讨论】:

    • 您能否详细说明适合您的 ipywidgets、widgetsnbextension、pandas-profiling 的版本?
    • 当然:ipywidgets==7.6.3pandas-profiling==3.0.0widgetsnbextension==3.5.1。这是您所期望的,还是您需要有关如何安装它们的更多信息?
    • 是否可以将报告导出为pdf或html?
    • 是的,您可以使用profile.to_file("your_report.html")。如果要下载 PDF,只需使用浏览器的打印功能将 HTML 保存为 PDF。您可以找到更多信息here
    【解决方案2】:

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

    pip install ipywidgets
    jupyter nbextension enable --py widgetsnbextension
    

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

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

    然后在你的笔记本中添加

    from ipywidgets import FloatProgress
    

    【讨论】:

      【解决方案3】:

      安装 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 实验室
      5. 建立 Juyter 实验室:jupyter lab build
      6. 启动 Jupyter 实验室

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-04-14
          • 2019-01-11
          • 1970-01-01
          • 1970-01-01
          • 2012-03-29
          • 2022-01-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多