昨天自己在安装python库的时候老是超时报错,后来换了源就解决了,换元方法分享给大家:
在使用Python的时候经常需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼。下载很慢,下载太久就会报超时,换元就是解决他的方法之一。
**
pip国内的一些镜像
**
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
豆瓣: https://pypi.doubanio.com/simple
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple wordcloud
或者
pip.exe install -i https://pypi.tuna.tsinghua.edu.cn/simple wordcloud
这样就会从清华这边的镜像去安装wordcloud库。
永久修改,一劳永逸:
1、打开电脑,在地址栏输入:%APPDATA%
2、在打开的目录下新建文件夹pip,在pip文件夹下新建pip.ini文件,输入以下内容并保存
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
上面代码换的是清华源,如果想要换其他的源只需要改url后面的链接即可