我在 Mac 上,按顺序安装了 numpy
和 sklearn
。现在,我面临着在 SO 上多次提到的这些错误:
sklearn "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal
ValueError: numpy.dtype has the wrong size, try recompiling
ImportError in importing from sklearn: cannot import name check_build
因此,我尝试通过卸载 numpy
并重新安装以前的版本来修复此错误。
1) sudo pip install --upgrade numpy
..gives 权限错误
...OSError: [Errno 1] Operation not allowed: '/tmp/pip-OVY0Vq-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy -1.8.0rc1-py2.7.egg-info'...
2) 我试过 brew uninstall numpy
,但 import numpy
即使在 shell 重启后仍然有效。
我唯一能想到的就是手动删除所有 numpy
文件,这些文件在 Mac 上似乎位于
sudo rm -rf/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
....但即使这样也给了我一个权限错误。是什么赋予了?
最佳答案
我猜你正在使用 MAC OS。 我做了一个解决方法来忽略 numpy 的现有版本(MAC 不会让你卸载),并安装升级版本。
命令:
pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy
对我来说工作得很好。
关于python - 如何在 MacOS 上正确卸载 numpy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39187374/