Python Pandas - 缺失必需的依赖项 ['numpy'] 1

70
自昨天起,在使用anaconda导入包时,我一直遇到以下错误: ImportError: Missing required dependencies ['numpy'] 我尝试卸载Anaconda和Python,并切换到Python 2.7,但仍然无法解决问题。这是我得到的代码: enter image description here 非常感谢任何帮助!

1
请尝试使用 conda install -f numpy 然后 conda install -f pandas - Carlos Cordoba
当我在32位环境下安装64位软件包时,出现了类似的错误。但是没有使用CONDA_FORCE_32BIT = 1。请参考 https://dev59.com/21sX5IYBdhLWcg3whvwn。 - poleguy
抱歉,有人能解释一下conda install -f numpy是做什么的吗?我以为numpy已经在Python中安装好了,不是吗? - haneulkim
29个回答

67

在将pandas升级到0.19.2后,我遇到了同样的问题。我通过以下方式从Windows命令行解决了它:

pip uninstall pandas -y
pip uninstall numpy -y
pip install pandas
pip install numpy

这也破坏了我的matplotlib安装,所以我也进行了卸载/安装。

对于一个看似例行升级来说,这是非常奇怪的行为。


3
TA正在使用Anaconda而非简单的Python安装。使用pip安装Numpy和Pandas会导致出错。我会为您进行翻译。 - Carlos Cordoba
3
@CarlosCordoba 我正在使用Python 3.4.1 :: Anaconda 2.1.0(64位),上述步骤对我很有效。我已经设置了pip并经常使用它来安装/升级软件包。昨天是我第一次遇到任何问题。上述步骤解决了我的问题,这与OP的问题相同。 - fireitup
3
在Windows上安装Anaconda3很顺利,但当我安装一个要求文件时出现了numpy错误。现在只需要前三行代码,因为安装pandas也会同时安装numpy。 - ski_squaw
这个方法虽然可行,但在重新安装之前,我不得不运行卸载命令多次以删除所有版本的numpy和pandas。这并不明显需要这样做。 - Tim Arnold
然后重新启动 shell。 - user3226167
显示剩余4条评论

18
如果尝试导入Numpy会发生什么?
你试过吗?
pip install --upgrade numpy
pip install --upgrade pandas

7
已为我修复。卸载并重新安装NumPy和pandas没有起作用。 - Elizabeth Santorella
对我来说也是一样,卸载和重新安装都没有帮助。需要按照特定的顺序进行升级。这是在Windows上的情况。 - Meshi

17

我必须安装这个其他的软件包:

sudo apt-get install libatlas-base-dev

看起来它是 numpy 的一个依赖项,但由于某种原因,pipapt-get 不会自动安装它。


8

我在使用numpy 1.16.x的最新版时遇到了问题。

问题通过以下方式解决:

python3 -m pip uninstall numpy

python3 -m pip install numpy==1.14.0


4
在Windows 10 Anaconda3-5.3.0-Windows-x86_64上,当我像这样运行脚本时%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe pandas_script_foo.py,我遇到了Missing required dependencies ['numpy']错误。在我的情况下,当在Windows cmd.exe会话中运行Anaconda python.exe时,缺少Anaconda包路径定义导致了此错误。numpy软件包并未丢失,只是找不到路径。Anaconda安装包含Windows快捷方式,用于配置每个脚本运行的路径。请参见%HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)目录中的快捷方式以获取示例。请参阅%HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py脚本,了解Anaconda如何配置路径。以下是一个示例Windows BAT文件,它调用cwp.py设置路径,然后运行Python脚本。这是Anaconda jupyter-lab快捷方式执行的命令副本。
%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3 ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\Scripts\jupyter-lab-script.py

如果您需要在Anaconda上执行Python脚本,并希望使用BAT文件方便地运行,上述的BAT文件示例应该可以解决问题。

这正是我需要的!我在 https://github.com/conda/conda/issues/2379 上一无所获——谢谢你。 - k..

4

你是否在安装miniconda和pandas时没有安装依赖项?

尝试先使用conda install numpypip install numpy安装numpy。

如果你使用的是Windows系统,可以从这里获取大多数需要编译的库的预编译版本。


2

我也遇到了同样的问题。这是在我升级numpy库后发生的。 在通过以下命令升级numpy库后,我还需要升级pandas库才能解决这个问题:

pip install --upgrade pandas

2

尝试:

    sudo apt-get install libatlas-base-dev

现在应该可以运行了。

否则,请尝试卸载并重新安装numpy和pandas。


2
pandas的数据操作能力是建立在numpy库之上的。某种程度上,numpy是pandas库的一个依赖项。如果你想使用pandas,你必须确保你也安装了numpy。当你使用pip安装pandas时,它会自动安装numpy。如果没有安装成功,请尝试以下命令:

pip install -U numpy pandas

对于conda

conda install numpy pandas


1
我遇到了同样的问题。 我安装了两个版本的numpy,分别是1.16.61.15.4,新安装的pandas不能正常工作。 我通过卸载所有版本的numpypandas,然后安装最新版本来解决这个问题。
$ pip uninstall  numpy pandas -y
Uninstalling numpy-1.16.6:
  Successfully uninstalled numpy-1.16.6
Uninstalling pandas-0.24.2:
  Successfully uninstalled pandas-0.24.2
$ pip uninstall  numpy pandas -y
Uninstalling numpy-1.15.4:
  Successfully uninstalled numpy-1.15.4
Cannot uninstall requirement pandas, not installed
$ pip uninstall  numpy pandas -y
Cannot uninstall requirement numpy, not installed
$ pip install  numpy pandas

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