python包管理工具pip无法下载包的问题

pip下载包执行install时失败,错误信息:

Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=’pypi.python.org’, port=443): Read timed out. (read timeout=15)”,)’: /simple/scipy/

疯狂重试后失败,又或者最后报错超时

D:\acadci-github\wk_client_tools\venv\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

还可能报错SSL错误

C:\Python27\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
 InsecurePlatformWarning
 Could not fetch URL https://pypi.org/simple/pygame/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pygame/ (Caused by SSLError(SSLrror(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) -

首先确定是否是pi'p版本过低,可以使用命令:python -m pip install --upgrade pip

第二如果不是版本问题,可能是网络问题,多试几次,如果任然报错,考虑使用国内镜像,可以用豆瓣,可以用清华的,个人喜欢用豆瓣的镜像,pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple (xxx要下载的包名)

第三,如果使用镜像任然无法成功,看错误信息是否为找不到对应包,有部分模块无法通过pip安装,需要手动下载对应的安装包执行setup.py命令

猜你喜欢

转载自blog.csdn.net/leaves_story/article/details/94654526