作者:四丢皮得
原文:https://www.jianshu.com/p/a502577dc12e
一、pip源修改
pip是python很强大的模块安装工具,但是由于官方pypi时常被墙,所以将pip源更换到国内,就可以解决这个问题。
目前有很多的可用源
豆瓣:http://pypi.douban.com/simple
清华:https://pypi.tuna.tsinghua.edu.cn/simple
1 临时使用
可以使用pip时添加参数 -i[url]
例如:
pip install -i http://pypi.douban.com/simple/ gevent
2 全局修改
2.1 linux
修改~/.pip/pip.conf,修改index-url至相应源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2.2 windows
修改c:\users\xxx\pip\pip.ini,修改index-url至相应源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
二、conda源修改
conda是一款好用的用于管理python虚拟环境的工具,可以有效的确保python模块库一致性(本人目前只用到的功能),而用conda install模块时(类似于pip),国内可能会导致速度慢或者被墙的情况,因此和pip类似,修改conda源至国内可解决此问题。
运行以下命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
或者直接修改.condarc文件
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
.condarc文件路径
windows c:\users\xxx
linux ~/.condarc
三、国内可用源列表
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/