我正在尝试学习机器学习,但无法解决以下错误。
[我的环境]
- Mac High Sierra 10.13.2
- Python3.4.5
- Numpy1.13.3
[命令]
$ python3 -c "import jupyter, matplotlib, numpy, pandas, scipy, sklearn"
[错误]
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
Traceback (most recent call last):
File "/Users/uekyo/ml/env/lib/python3.4/site-packages/pandas/__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "/Users/uekyo/ml/env/lib/python3.4/site-packages/pandas/_libs/__init__.py", line 4, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib
ImportError: numpy.core.multiarray failed to import
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/uekyo/ml/env/lib/python3.4/site-packages/pandas/__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: numpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
[我尝试过的事情]
我知道 numpy 是错误的。所以我尝试了下面的东西,但错误仍然出现。
1
sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_old
2
pip3 uninstall numpy
pip3 install numpy -I
谢谢。
原文由 uekyo 发布,翻译遵循 CC BY-SA 4.0 许可协议
似乎这是由于 pandas 版本高于 0.21.0 和由 TensorFlow 拉取的 numpy 版本 1.13.3 不能很好地协同工作。
这是我最终修复它的方法: