【问题标题】:How to correctly uninstall numpy on MacOSX?如何在 MacOS 上正确卸载 numpy?
【发布时间】:2017-01-04 08:53:35
【问题描述】:

我在 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

....但即使这样也给了我一个权限错误。是什么赋予了?

【问题讨论】:

  • 我可能会手动删除文件,然后为了避免错误和可能损坏您的操作系统,您应该在虚拟环境中安装您的软件包。例如docs.python-guide.org/en/latest/dev/virtualenvs
  • 但是,这些是要删除的正确文件吗?
  • 即使使用sudo.....它也不会让我删除它们!!建议??
  • 好的,我试试sudo chmod 777 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy,我得到chmod: Unable to change file mode on /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy: Operation not permitted。什么给了?
  • 只有我一个人认为这不应该那么难!!!??

标签: python macos python-2.7 numpy


【解决方案1】:

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

命令:

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

对我来说工作得很好。

【讨论】:

  • 添加 -ignore-installed 也解决了我在 centos 上的问题。谢谢!
  • 我不得不使用:sudo pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy 它对我有用
  • 你拯救了我的一天!
【解决方案2】:

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

sudo pip install numpy --ignore-installed numpy

【讨论】:

    【解决方案3】:

    为了解决这个问题,我执行了以下操作:(请注意,由于我没有彻底测试,我并不完全清楚其中哪一个解决了问题)。

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

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

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

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

    【讨论】:

      【解决方案4】:

      什么适用于我的 Mac OS 10.13.6 (High 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. (重新)使用以下选项安装 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 @987654321@ (13.9MB) 100% |████████████████████████████████| 13.9MB 921kB/s Installing collected packages: numpy Successfully installed numpy-1.16.2

      【讨论】:

        【解决方案5】:

        如果你使用的是 brew 版本的 python

        brew uninstall numpy
        

        如果你使用的是mac版的python:

        python 2.7

        pip uninstall numpy
        

        蟒蛇3

        pip3 uninstall numpy
        

        【讨论】:

        • pip upgradepip uninstall 相同,然后是pip install
        • 你运行的是哪个python版本的mac版还是brew版的?,
        • 我怎么知道?
        • 默认情况下它是mac版本,即使你已经使用brew安装了python,你应该尝试使用pip或pip3安装numpy searn,同样对于python2.7和python3你必须单独安装库
        • python -c 或 python3 -c 用于检查你正在使用的 python 的路径
        【解决方案6】:

        使用 easy_install 更新 numpy 对我有用。

        sudo easy_install numpy

        【讨论】:

          【解决方案7】:

          我遇到这个问题最好安装“anaconda”,因为它会处理所有这些问题。

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

          【讨论】:

            猜你喜欢
            • 2015-09-19
            • 2018-11-02
            • 1970-01-01
            • 2018-06-02
            • 2021-06-05
            • 2021-07-18
            • 1970-01-01
            • 2020-11-13
            • 2018-09-16
            相关资源
            最近更新 更多