更改pip源为国内镜像地址

2018-06-06  本文已影响0人  信仰与初衷

经常在使用python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼。


修改源

以ubuntu16.04为例进行说明。

国内源(新版ubuntu要求使用https源,要注意。):

还有一些别的没有列出。

临时使用:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider
永久修改:
[global]  
index-url = http://mirrors.aliyun.com/pypi/simple/ 
[install]  
trusted-host=mirrors.aliyun.com  
timeout = 150 # 超时时间设置(单位为s),一般可以设置的长一些
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
上一篇 下一篇

猜你喜欢

热点阅读