Anaconda上的SSLError解决方法

前情提要

在安装新版Anaconda(py3.6以上)时,有几率会碰上讨厌的SSLError(详情见下),网上的解决方法并没有一针见血,此答案主要用来做一个记录(逃

问题描述:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)
CondaHTTPError: HTTP 000 CONNECTION FAILED for url

python上的SSLError信息

pip install 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/
WARNING: Retrying (Retry(total=3, 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/
WARNING: Retrying (Retry(total=2, 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/
WARNING: Retrying (Retry(total=1, 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/
WARNING: Retrying (Retry(total=0, 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/
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

Conda上的SSLError信息

conda install numpy

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url 
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))

解决方法

将以下三个位置加入环境变量:

D:\Anaconda3; 
D:\Anaconda3\Scripts; 
D:\Anaconda3\Library\bin 

其中D:\Anaconda3\Library\bin 是关键,因为该文件夹下有openssl.exe,有的安装Anaconda教程在手动加环境变量的过程中,没有加入第三个位置,导致了巨大巨大超级超级低级的失误
Anaconda上的SSLError解决方法_第1张图片

你可能感兴趣的:(小技巧)