【问题标题】:mac catalina pip cannot install numpy (zsh)mac catalina pip 无法安装 numpy (zsh)
【发布时间】:2020-09-08 03:34:40
【问题描述】:

我是 python 新手。最近,我想在我的 macOS 上安装 numpy。我已经安装了brewpythonpip。另外,我将pip pip3python 别名为python3。但是,当我运行 pip install numpy 时,它会显示一个错误。

我也很困惑,由于别名的原因,我应该使用pip3 来安装numpy。但是为什么警告是关于 python2.7 的呢?

➜  ~ which python
python: aliased to /usr/local/bin/python3.6
➜  ~ which pip
pip: aliased to /usr/local/bin/pip3
➜  ~ pip install numpy
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (1.8.0rc1)

【问题讨论】:

    标签: python python-3.x python-2.7 numpy pip


    【解决方案1】:

    如果您无法访问计算机,则很难找到错误的确切原因。看来,尽管您使用 Python 2 的别名,但 Python 3 不能使用 Python 2 的模块。

    您可以使用 pip 作为模块来强制 Python 版本,例如。 g.:

    python3 -mpip install numpy
    

    /usr/local/bin/python3.6 -mpip install numpy
    

    【讨论】:

    • 您好,感谢您的回答。但是,当我尝试这两行时,我也得到了错误:(
    • pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用。无法获取 URL pypi.org/simple/pip:确认 ssl 证书时出现问题:HTTPSConnectionPool(host='pypi.org', port=443):最大重试次数超出 url:/simple/pip/(由 SSLError(“Can '不连接到 HTTPS URL,因为 SSL 模块不可用。",)) - 跳过
    • 您的 Mac 上可能缺少 SSL 库。 Apple 前段时间用 Crypto 取代了 OpenSSL。但是你可以通过 brew 安装 OpenSSL。
    • 我已经尝试过“brew uninstall openssl; brew install openssl”或“brew reinstall openssl”但我仍然得到错误,我是不是做错了什么?顺便说一句,谢谢