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

Cannot import or install pandas-profiling in Jupyter Notebook

我已经在技术上安装了 pandas-profiling 使用

pip install 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'

First Error Image

所以我尝试在 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

Second Error Image

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

根据评论,我找出了问题所在。我必须在 Anaconda root env 之外安装 jupyter notebook 并从终端打开它。

pip3 install jupyter notebook

一旦我这样做了,它就正确导入了。

步骤:

  1. Download the ZIP
  2. 打开 Anaconda Prompt 并转到目录并将文件解压缩到文件夹

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

  1. 然后输入python setup.py安装

  2. 现在您可以使用:

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

参考:Pandas profiling

对于其他希望解决此问题的人,请尝试以下替代步骤:

  1. 运行 pip install pandas-profiling 命令在 jupyter notebook 的单独单元格中。
  2. 在此之后只需重新启动内核并再次 运行。这应该绝对有效。为我工作。
!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

来自 Anaconda 提示:

conda install -c conda-forge pandas-profiling