熊猫失踪所需的依赖['numpy']

时间:2017-05-27 19:24:44

标签: python pandas numpy

enter image description here

我目前正在关注机器学习的初学者介绍。 输入命令时: 在终端的python shell中import pandas as pd,我得到一个错误:

  

ImportError:缺少必需的依赖项['numpy']。

我已经查看了其他类似问题,尝试了该解决方案,但仍然收到了相同的错误。

4 个答案:

答案 0 :(得分:2)

看起来你可能在Mac上运行,也许使用默认的系统python。无论出于何种原因,您都没有完整的安装。您有pandas但不是numpy。我不确定您使用的教程使用哪些软件包,但我建议安装Anaconda python distribution,因为它包含pandas,所有依赖项等等,包括scikit-learn包经常用于机器学习。

如果您想了解更多关于在Mac上安装用于机器学习的Python环境的信息,那么machinelearningmastery.com上有一个很好的tutorial

答案 1 :(得分:2)

这与不兼容性无关。正如@Peter所说,你根本就没有NumPy,应该通过Anaconda安装。以下是pandas中的代码,它给出了错误:

msg_name

请注意,这里没有关于版本的信息。

答案 2 :(得分:0)

我遇到了同样的问题。我不知道问题的原因是什么,但它似乎处理了如何安装numpy。您可以尝试以下方法:

  1. 安装pandas
  2. 卸载numpy
  3. here
  4. 下载满足您需求的numpy whl
  5. 从已下载的whl
  6. 安装numpy

    这对我有用!

答案 3 :(得分:0)

当我忘记激活环境时,我在Anaconda安装中收到了相同的错误消息:

测试代码:import_pandas.py:

import pandas
print('Pandas import succeeded!')

使用ImportError运行import_pandas.py:

Microsoft Windows [Version 10.0.16299.1146]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\peter\demo>python import_pandas.py
Traceback (most recent call last):
  File "import_pandas.py", line 1, in <module>
    import pandas
  File "C:\Users\peter\AppData\Local\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

但是,在激活conda之后,一切都可以正常运行:

C:\Users\peter\demo>activate
C:\Users\peter\demo>conda.bat activate

(base) C:\Users\peter\demo>python import_pandas.py
Pandas import succeeded!