使用pip在python中下载flask包时出错

Error in downloading flask package in python using pip

我正在尝试在python3中安装flask。 在给出命令python -m pip install flask时,我收到错误

Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:748)'),)': /simple/flask/ Retrying (Retry(total=3,
connect=None, read=None, redirect=None, status=None)) after connection
broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed (_ssl.c:748)'),)': /simple/flask/ Retrying
(Retry(total=2, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:748)'),)': /simple/flask/ Retrying (Retry(total=1,
connect=None, read=None, redirect=None, status=None)) after connection
broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed (_ssl.c:748)'),)': /simple/flask/ Retrying
(Retry(total=0, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:748)'),)': /simple/flask/ Could not fetch URL
https://pypi.python.org/simple/flask/: There was a problem confirming
the ssl certificate: HTTPSConnectionPool(host='pypi.python.org',
port=443): Max retries exceeded with url: /simple/flask/ (Caused by
SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed (_ssl.c:748)'),)) - skipping Could not find a version
that satisfies the requirement flask (from versions: ) No matching
distribution found for flask


这是工作解决方案:

1
python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip

您可以安装任何替换"--upgrade pip"的pkg。

对于permenant解决方案,您需要编辑pip.ini文件并添加以下内容:

1
2
3
4
5
[global]
trusted-host=
    pypi.python.org
    pypi.org
    files.pythonhosted.org