简体   繁体   English

Mac OS Python 3.6 无法通过 pip 安装任何包(TLS/SSL 证书)

[英]Mac OS Python 3.6 unable to pip install any package (TLS/SSL certificate)

I'm on Mac OS 10.15.2 (Catalina).我使用的是 Mac OS 10.15.2 (Catalina)。 Python 2 and 3.7 were pre-installed ( /usr/bin/python , /usr/bin/python3 ), and I have installed Python 3.6 with brew ( /usr/local/bin/python3 ). Python 2 和 3.7 已预先安装( /usr/bin/python/usr/bin/python3 ),并且我已经使用 brew ( /usr/local/bin/python3 )安装了 Python 3.6。 Also, I'm using a virtual environment as follows:另外,我正在使用虚拟环境,如下所示:

  1. virtualenv -p <dir_python> venv (to create venv) virtualenv -p <dir_python> venv (创建 venv)
  2. source venv/bin/activate (to activate venv) source venv/bin/activate (激活 venv)
  3. pip install <package> (to install packages) pip install <package> (安装包)

When I use Python 2 and 3.7 to create the virtual env, everything works fine.当我使用 Python 2 和 3.7 创建虚拟环境时,一切正常。 Whenever I'm using Python 3.6 I cannot install anything .每当我使用 Python 3.6 时,我都无法安装任何东西 For example, with 'numpy', I get the following:例如,使用“numpy”,我得到以下信息:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/numpy/

... retrying for four more times ...  

Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)

ERROR: No matching distribution found for numpy

I have tried a few things from other posts that described what was appearing to be something similar but none of the following helped , such as:我尝试了其他帖子中的一些内容,这些内容描述了看似相似的内容,但以下内容均没有帮助,例如:

  • Uninstalling and re-installing Python 3.6卸载并重新安装 Python 3.6
  • pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools

Any help is much appreciated!任何帮助深表感谢! Thanks.谢谢。

I've had the same issue.我有同样的问题。

To fix it, I just updated python using brew.为了解决这个问题,我只是使用 brew 更新了 python。

brew upgrade python3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM