Python pip安装包 read time out

例如要安装numpy
正常情况下,用pip install numpy(或pip3 install numpy)即可。但是这个过程是从源下载,有可能会遇到网不好,或者是源不好
会出现如下这种错误
raise ReadTimeoutError(self._pool, None, ‘Read timed out.’)
pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=’files.pythonhosted.org’, port=443): Read timed out.

解决办法有两种:

1.修改下载源。

  • 方法一:
    pip install numpy -i http://pypi.douban.com/simple —trusted-host pypi.douban.com
  • 方法二:.配置pip源,一劳永逸
    找到C:\Users\xxx, “xxx”是用户名, 新建一个pip文件夹, 并在里面新建一个pip.ini, 打开输入:
    [global]
    timeout = 6000
    index-url = https://pypi.douban.com/simple
    这样以后下载的时候,就自动从豆瓣的源下。

2.先从网页下载,再本地安装。

有一个网址:https://www.lfd.uci.edu/~gohlke/pythonlibs/
这个网站就是一些安装包的下载链接。
Python pip安装包 read time out
从里面搜索自己要下载的包即可。
Python pip安装包 read time out
例如我要安装的是vtk。
1.下载对应的安装包
2.通过pip install VTK-8.1.1-cp36-cp36m-win_amd64.whl,很快就能安装成功。
Python pip安装包 read time out
3.测试一下,安装成功!
Python pip安装包 read time out