windows 10安装Anaconda后pip报SSL错解决

问题

新装的系统,安装anaconda(python=3.7)后

# pip install xxx
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting xxx
    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/xxx/
  ......
     Could not fetch URL https://pypi.org/simple/xxx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/ssl/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
    Could not find a version that satisfies the requirement xxx(from versions: )
No matching distribution found for xxx
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

以前安装完的anaconda都是直接用的,现在安装了最新的版本反而直接出错,找了很多地方都没解决,思考一下,ssl模块出错。

# python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ssl
Traceback (most recent call last):
  File "", line 1, in 
ImportError: DLL load failed: 找不到指定的模块。

可能openssl没有安装的原因,所以装了一下openssl,https://slproweb.com/products/Win32OpenSSL.html
可以下载编译好的,或者以任何方式安装openssl,再次运行pip正常。

更新,评论里有人贴了更好的解决办法,把Anaconda3\Library\bin也添加到环境变量即可解决。

你可能感兴趣的:(python)