Python Pandas - 缺少必需的依赖项 ['numpy'] 1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41859939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Pandas - Missing required dependencies ['numpy'] 1
提问by saib
Since yesterday I've had this error when I try to import packages on anaconda :
从昨天开始,当我尝试在 anaconda 上导入包时遇到了这个错误:
ImportError: Missing required dependencies ['numpy']
ImportError: Missing required dependencies ['numpy']
I have tried un-installing Anaconda and Python, switching to Python 2.7 but nothing works it's still the same error, here is the code I get :
我试过卸载 Anaconda 和 Python,切换到 Python 2.7 但没有任何作用它仍然是相同的错误,这是我得到的代码:
Any help is really appreciated thanks !
非常感谢任何帮助!
回答by fireitup
I had this same issue immediately after upgrading pandas to 0.19.2. I fixed it with the following install/uninstall sequence from the windows cmd line:
将熊猫升级到 0.19.2 后,我立即遇到了同样的问题。我使用 Windows cmd 行中的以下安装/卸载顺序修复了它:
pip uninstall pandas -y
pip uninstall numpy -y
pip install pandas
pip install numpy
This also broke my matplotlib install so I uninstalled/installed that as well.
这也破坏了我的 matplotlib 安装,所以我也卸载/安装了它。
Very odd behavior for a seemingly routine upgrade.
对于看似常规升级的非常奇怪的行为。
回答by McKenzie
What happens if you try to import numpy?
如果您尝试导入 numpy 会发生什么?
Have you tried'
你有没有尝试过'
pip install --upgrade numpy
pip install --upgrade pandas
回答by dashnick
I had to install this other package:
我必须安装这个其他包:
sudo apt-get install libatlas-base-dev
Seems like it is a dependency for numpy
but the pip
or apt-get
don't install it automatically for whatever reason.
好像它是一个依赖numpy
,但pip
还是apt-get
没有出于某种原因自动安装它。
回答by veaceslav.kunitki
I had this problem with last version of numpy 1.16.x
我在 numpy 1.16.x 的最新版本中遇到了这个问题
Problem resolved with
问题解决了
python3 -m pip uninstall numpy
python3 -m pip install numpy==1.14.0
python3 -m pip uninstall numpy
python3 -m pip install numpy==1.14.0
回答by Dennis Sakva
Did you install miniconda and pandas without dependencies?
您是否安装了没有依赖项的 miniconda 和 pandas?
Try installing numpy first with conda install numpy
or pip install numpy
.
首先尝试使用conda install numpy
或安装 numpy pip install numpy
。
If you're on Windows you can get pre-compiled versions of most libraries that require compilation from here.
如果您使用的是 Windows,您可以从这里获得大多数需要编译的库的预编译版本。
回答by ace_racer
I also faced the same issue. It happened to me after I upgraded my numpy library. It was resolved in my case by upgrading my pandas library as well after upgrading my numpy library using the below command:
我也面临同样的问题。我升级了 numpy 库后发生了这种情况。在我的情况下,通过使用以下命令升级我的 numpy 库后升级我的 Pandas 库解决了这个问题:
pip install --upgrade pandas
回答by user1243477
On Windows 10 Anaconda3-5.3.0-Windows-x86_64 I had the Missing required dependencies ['numpy']
error when running scripts as so, %HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe pandas_script_foo.py
.
在 Windows 10 Anaconda3-5.3.0-Windows-x86_64 上Missing required dependencies ['numpy']
运行脚本时出现错误,%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe pandas_script_foo.py
.
In my case the error was caused by missing Anaconda package PATH definitions when running Anaconda python.exe in a windows cmd.exe session. The numpy package is not missing. It just can't be found on the PATH.
在我的情况下,错误是由于在 Windows cmd.exe 会话中运行 Anaconda python.exe 时缺少 Anaconda 包 PATH 定义引起的。numpy 包没有丢失。它只是无法在 PATH 上找到。
The Anaconda installation includes windows shortcuts that give examples of configuring the PATH per script run. See the shortcuts in the %HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
directory for examples.
See the %HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py
script to see how Anaconda configures PATH.
Anaconda 安装包括 Windows 快捷方式,这些快捷方式提供了每个脚本运行配置 PATH 的示例。有关%HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
示例,请参阅目录中的快捷方式。查看%HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py
脚本以了解 Anaconda 如何配置 PATH。
Below is an example windows BAT file that calls cwp.py to setup PATH, and then run a python script. Its a copy of the commands the Anaconda jupyter-lab shortcut executes.
下面是一个示例 windows BAT 文件,它调用 cwp.py 来设置 PATH,然后运行 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
If you need to execute python scripts on Anaconda with the conveniance of running a BAT file, the above BAT file example should do the trick.
如果您需要在 Anaconda 上执行 python 脚本并方便地运行 BAT 文件,上面的 BAT 文件示例应该可以解决问题。
回答by Harshavardhan Reddy
The data manipulation capabilities of pandas are built on top of the numpy library. In a way, numpy is a dependency of the pandas library. If you want to use pandas, you have to make sure you also have numpy. When you install pandas using pip
, it automatically installs numpy. If it doesn't, try the following
pandas 的数据操作能力建立在 numpy 库之上。在某种程度上,numpy 是 pandas 库的依赖项。如果你想使用pandas,你必须确保你也有numpy。当您使用 安装 pandas 时pip
,它会自动安装 numpy。如果没有,请尝试以下操作
pip install -U numpy pandas
pip install -U numpy pandas
For conda
对于康达
conda install numpy pandas
conda install numpy pandas
回答by maj
First, try to import numpy on it's own, like so:
首先,尝试自己导入 numpy,如下所示:
import numpy as np
I got this message:
我收到了这条消息:
ImportError: Something is wrong with the numpy installation. While importing
we detected an older version of numpy in
['/home/michael/.local/lib/python3.6/site-packages/numpy']. One method of
fixing this is to repeatedly uninstall numpy until none is found, then
reinstall this version.
So do what it says, keep uninstalling numpy until there is none, and then reinstall.
所以按照它说的做,继续卸载numpy直到没有,然后重新安装。
This worked for me.
这对我有用。
回答by Julian013
I had the same issue. It was because I had multiple versions of numpy
installed. Remove all versions by repeatedly using:
我遇到过同样的问题。那是因为我numpy
安装了多个版本。通过重复使用删除所有版本:
pip uninstall numpy
pip uninstall numpy
Then re-install it with the command:
然后使用以下命令重新安装它:
pip install numpy
pip install numpy