如何在MacOSX上正确卸载numpy?

时间:2016-08-28 01:59:06

标签: python macos python-2.7 numpy

我在Mac上,我按顺序安装了numpysklearn。现在,我已经多次面对已经在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 ..给出权限错误

...OSError: [Errno 1] Operation not permitted: '/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

....但即便如此,也会给我一个许可错误。是什么赋予了?

7 个答案:

答案 0 :(得分:66)

我猜你正在使用MAC OS。 我做了一个解决方法,忽略现有版本的numpy(MAC不允许卸载),并安装升级版本。

命令:

pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy

对我来说很好。

答案 1 :(得分:8)

当我尝试在MAC中安装熊猫时,我也得到了此信息,但是以下命令可以帮助我解决问题。以下命令将忽略任何以前安装的版本。虽然不确定它是否真的可以解决问题,但您也可以尝试一下:

sudo pip install numpy --ignore-installed numpy

答案 2 :(得分:5)

为了解决这个问题,我做了以下几点:(注意我并不完全清楚哪个解决了这个问题,因为我没有彻底测试过。)

1)在Python.org上安装python而不是Mac的愚蠢版本

2)重新安装了所有模块,例如numpyscipymatplotlibsklearn并根据此来源运行:hash -r pythonSymbol not found: __PyCodecInfo_GetIncrementalDecoder,因为它不会使python使用模块的缓存版本。

3)然后,我意识到我遇到了这个问题:https://github.com/scipy/scipy/issues/5093。要解决这个问题,我必须确保使用scipy而不是python -m pip install scipy='0.15.0'来安装pip install scipy='0.15.0'模块,因为这解决了基于此来源的问题:Can't load Python modules installed via pip from site-packages directory

因此,总而言之,事实证明pip安装的内容与终端执行python时导入的内容之间存在很大差异。因此,为了确保您使用pip将模块安装到特定的python中,您可以使用python -m pip install <package name>

答案 3 :(得分:1)

适用于我的Mac OS 10.13.6(高Sierra)的版本:

  1. 只需继续卸载numpy: $sudo -H pip uninstall numpy DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling numpy-1.16.2: Would remove: /Library/Python/2.7/site-packages/numpy-1.16.2.dist-info/* /Library/Python/2.7/site-packages/numpy/* ... Proceed (y/n)? y Successfully uninstalled numpy-1.16.2 $sudo -H pip uninstall numpy DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling numpy-1.14.2: Would remove: /Library/Python/2.7/site-packages/numpy-1.14.2.dist-info/* ... Proceed (y/n)? y Successfully uninstalled numpy-1.14.2

  2. (re-)使用以下选项安装numpy: $ sudo -H pip install --ignore-installed numpy
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting numpy Downloading https://files.pythonhosted.org/packages/bc/90/3e71b5392bd81d8559917ee38857bb2e4b92c88e87211a68e339127b86f5/numpy-1.16.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (13.9MB) 100% |████████████████████████████████| 13.9MB 921kB/s Installing collected packages: numpy Successfully installed numpy-1.16.2

答案 4 :(得分:0)

如果你正在使用brew版本的python

brew uninstall numpy

如果你正在使用mac版的python:

python 2.7

pip uninstall numpy

python 3

pip3 uninstall numpy

答案 5 :(得分:0)

使用easy_install更新numpy对我有用。

  

sudo easy_install numpy

答案 6 :(得分:0)

我更好地面对这个问题安装“anaconda”,因为它会处理所有这些。

参考https://conda.io/docs/user-guide/install/macos.html