这与不兼容没有关系。 正如@Peter所提到的,您只是没有安装NumPy,应该通过Anaconda安装。 这里是在pandas中导致错误的代码:
# Let users know if they're missing any of our hard dependencies
hard_dependencies = ("numpy", "pytz", "dateutil")
missing_dependencies = []
for dependency in hard_dependencies:
try:
__import__(dependency)
except ImportError as e:
missing_dependencies.append(dependency)
if missing_dependencies:
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
del hard_dependencies, dependency, missing_dependencies
注意这里没有提到版本信息。
我曾经遇到过同样的问题。我不知道问题的原因,但似乎与numpy的安装方式有关。你可以尝试以下操作:
这对我有效!
当我忘记激活环境时,我的Anaconda安装程序会显示相同的错误消息:
测试代码:import_pandas.py:
import pandas
print('Pandas import succeeded!')
使用 import_pandas.py 运行时出现 ImportError:
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!