Windows下,python pip安装时ReadTimeoutError解决办法

通常状况下PIP出现ReadTimeoutError都是由于被GFW给墙了,因此通常遇到这种问题,咱们能够选择国内的镜像来解决问题。html

在Windows下:python

C:\Users\Administrator\下新建pip文件夹,在建立pip.ini文件,拷贝下面代码进去,保存。linux

 

[global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

 

其实就是把python的源换成了清华源,应该能解决问题。ubuntu

 

国内源:

新版ubuntu要求使用https源,要注意。windows

清华:https://pypi.tuna.tsinghua.edu.cn/simpleide

阿里云:http://mirrors.aliyun.com/pypi/simple/阿里云

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/url

华中理工大学:http://pypi.hustunique.com/code

山东理工大学:http://pypi.sdutlinux.org/pyspider

豆瓣:http://pypi.douban.com/simple/

临时使用:

能够在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。

永久修改,一劳永逸:

Linux下,修改 ~/.pip/pip.conf (没有就建立一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容以下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host=mirrors.aliyun.com windows下,直接在user目录中建立一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。

相关文章
相关标签/搜索