Python 如何在 MacOSX 上正确卸载 numpy?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39187374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to correctly uninstall numpy on MacOSX?
提问by Sother
I'm on a Mac, and I installed numpy
and sklearn
in that order. Now, I'm faced with these errors that have already been mentioned on SO several times:
我在Mac上,我安装numpy
,并sklearn
按照这个顺序。现在,我面临着已经多次提到的这些错误:
sklearn "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal
sklearn“numpy.dtype 的大小错误,请尝试重新编译”在 pycharm 和终端中
ValueError: numpy.dtype has the wrong size, try recompiling
ValueError: numpy.dtype 大小错误,尝试重新编译
ImportError in importing from sklearn: cannot import name check_build
从 sklearn 导入时出现导入错误:无法导入名称 check_build
So, I try to remediate this error by uninstalling numpy
, and reinstalling a previous version.
因此,我尝试通过卸载numpy
并重新安装以前的版本来修复此错误。
1) sudo pip install --upgrade numpy
..gives permission error
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'...
...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) I tried brew uninstall numpy
, but import numpy
still works even after a shell restart.
2)我试过brew uninstall numpy
,但import numpy
即使在shell重新启动后仍然有效。
The only thing left I can think of is to manually delete all of the numpy
files, which, on a Mac seeem to be found under
sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
我唯一能想到的就是手动删除所有numpy
文件,在 Mac 上似乎可以在下面找到这些文件
sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
....but even that gives me a permission error. what gives?
....但即使这样也给了我一个权限错误。是什么赋予了?
采纳答案by Sother
To solve this, I did the following: (note that it is not entirely clear to me which of these solved the problem, since I didn't test thoroughly).
为了解决这个问题,我做了以下事情:(请注意,我并不完全清楚哪些解决了问题,因为我没有进行彻底的测试)。
1) Installed python at Python.org instead of Mac's stupid version
1) 在 Python.org 安装 python 而不是 Mac 的愚蠢版本
2) re-installed all of the modules like numpy
, scipy
, matplotlib
, sklearn
and ran this:hash -r python
according to this source: Symbol not found: __PyCodecInfo_GetIncrementalDecoder, because it doesn't make python use the cached versions of the modules.
2) 重新安装所有模块,如numpy
, scipy
, matplotlib
,sklearn
并运行:hash -r python
根据此来源:找不到符号:__PyCodecInfo_GetIncrementalDecoder,因为它不会使python使用模块的缓存版本。
3) Then, I realized that I had this issue: https://github.com/scipy/scipy/issues/5093. To solve it, I had to make sure I installed the scipy
module using python -m pip install scipy='0.15.0'
instead of just pip install scipy='0.15.0'
, because this solved the issue based on this source: Can't load Python modules installed via pip from site-packages directory.
3)然后,我意识到我有这个问题:https: //github.com/scipy/scipy/issues/5093。为了解决这个问题,我必须确保我scipy
使用python -m pip install scipy='0.15.0'
而不是仅仅安装了模块pip install scipy='0.15.0'
,因为这解决了基于以下来源的问题:无法加载通过 pip 从 site-packages 目录安装的 Python 模块。
So, in conclusion it turns out there really is a big different between what is installed by pip
, and what is imported when python
is executed from the terminal. So, to ensure that you are using the pip to install the modules into a particular python, you can use python -m pip install <package name>
.
因此,总而言之,由 安装的内容pip
与python
从终端执行时导入的内容之间确实存在很大差异。因此,为了确保您使用 pip 将模块安装到特定的 Python 中,您可以使用python -m pip install <package name>
.
回答by Zubin
I guess you are using MAC OS. I did a workaround to ignore the existing version of numpy (which MAC won't let you uninstall), and install an upgraded version.
我猜你正在使用 MAC 操作系统。我做了一个解决方法来忽略 numpy 的现有版本(MAC 不会让你卸载),并安装升级版本。
Command :
命令 :
pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy
Worked fine for me.
对我来说效果很好。
回答by Lola Yan
I also getting this when I try to install pandas in MAC, but following command help me to get work around. Following command will ignore any previously installed version. Not sure it really fix issue behind though, but you can also have a try:
当我尝试在 MAC 中安装 Pandas 时,我也得到了这个,但是下面的命令可以帮助我解决这个问题。以下命令将忽略任何以前安装的版本。不确定它是否真的解决了后面的问题,但您也可以尝试一下:
sudo pip install numpy --ignore-installed numpy
回答by Tan Nguyen
What works for my Mac OS 10.13.6 (High Sierra):
什么适用于我的 Mac OS 10.13.6 (High Sierra):
Just keep uninstalling 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
(re-) Install numpy with option:
$ 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
继续卸载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
(重新)使用选项安装 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
回答by SinOfWrath
If you're using the brew version of python
如果您使用的是 brew 版本的 python
brew uninstall numpy
If you're using the mac version of python:
如果您使用的是 mac 版本的 python:
python 2.7
蟒蛇 2.7
pip uninstall numpy
python 3
蟒蛇 3
pip3 uninstall numpy
回答by Rafael Rios
It worked for me using easy_install to update numpy.
使用easy_install更新numpy对我有用。
sudo easy_install numpy
须藤easy_install numpy
回答by Rafael Rios
I faced this issue better go with installing "anaconda" as it will take care of all this.
我最好安装“anaconda”来解决这个问题,因为它会解决所有这些问题。
Refer https://conda.io/docs/user-guide/install/macos.html
参考 https://conda.io/docs/user-guide/install/macos.html