由于使用pip安装Django失败,制定解决方案并进行备忘
这篇文章的内容 (zhè de
由于安装Django时出现了一个奇怪的错误“证书验证出了问题”,我将其记录下来作为备忘。
目录
1. 环境
2. 错误内容
3. 解决方法
1. 环境
Windows 10
Python 3.7.8
2. 错误的内容
当我试图安装Django时出现了下面这样可疑的警告。

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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/django/
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/django/
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/django/
Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLErrERROR: Could not find a version that satisfies the requirement django (from versions: none)
ERROR: No matching distribution found for django
调查后发现有几种解决方法,但我暂时选择了最简单的一种,“升级Python版本”。
3. 解决办法
在Python官网上安装最新的3.8.4版本(https://www.python.org/downloads/release/python-384/)。这样一来,
Collecting django
Downloading Django-3.0.8-py3-none-any.whl (7.5 MB)
|████████████████████████████████| 7.5 MB ...
Collecting pytz
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB ...
Collecting asgiref~=3.2
Downloading asgiref-3.2.10-py3-none-any.whl (19 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB ...
Installing collected packages: pytz, asgiref, sqlparse, django
Successfully installed asgiref-3.2.10 django-3.0.8 pytz-2020.1 sqlparse-0.3.1
我成功了。