无法在Jupyter Notebook中导入或安装pandas-profiling

5

我已经使用

pip install pandas-profiling

技术上已经安装了 pandas-profiling,但是当我尝试导入它时,出现以下错误:

import numpy as np
import pandas as pd
import pandas_profiling
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-e1a23f2a6f04> in <module>()
  1 import numpy as np
  2 import pandas as pd
  3 import pandas_profiling

  ModuleNotFoundError: No module named 'pandas_profiling'

第一个错误图片

然后我尝试在Jupyter Notebook中安装它,也遇到了以下错误:

import sys
!{sys.executable} -m pip install pandas-profiling

 Collecting pandas-profiling
 Could not find a version that satisfies the requirement pandas-profiling 
 (from versions: )
 No matching distribution found for pandas-profiling

第二个错误图片

我也无法使用conda安装它,因为我无法出于某种原因连接到conda.anaconda.org。


1
你是从包含模块的环境中启动笔记本吗? - mlenthusiast
我正在Anaconda根环境中启动笔记本。 - genelaw03
我认为您没有在根环境中安装的权限,因为您是一个用户。因此,您无法从根环境中使用它。您需要在可以编写的环境中正确安装它。 - vb_rises
5个回答

6

如果其他人想要解决这个问题,请尝试以下替代步骤:

  1. 在jupyter笔记本的一个单独单元格中运行pip install pandas-profiling 命令。
  2. 之后,只需重新启动内核并再次运行即可。这应该一定能够解决问题。对我起作用了。

4

根据评论,我能够找出这个问题。我需要在Anaconda根环境之外安装jupyter notebook,并从终端打开它。

pip3 install jupyter notebook

我这样做后,它成功导入了。


1
请问您能否解释一下如何完成这个步骤? - Lucas

1

从Anaconda提示符:

conda install -c conda-forge pandas-profiling


0
!pip install pandas_profiling  # Run this from Jupytor notebook Ignore the warnings if any 
from pandas_profiling import ProfileReport #restart the kernel if throws error
ProfileReport(df)  

注意:这个方法在我的Windows 10电脑上有效。

0

步骤:

  1. 下载ZIP文件
  2. 打开Anaconda Prompt并进入目录,将文件提取到文件夹中

cd C:\Users\farah\Downloads\pandas-profiling-master\pandas-profiling-master

  1. 然后输入python setup.py install

  2. 现在您可以使用:

import pandas_profiling as pp
df = pd.read_csv('1234.csv')
pp.ProfileReport(df)

参考资料:Pandas profiling


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接