一、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://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
中科大
http://mirrors.ustc.edu.cn/anaconda/pkgs/free/