豆瓣鏡像地址:https://pypi.douban.com/simple/python
雖然用easy_install和pip來安裝第三方庫很方便
它們的原理其實就是從Python的官方源pypi.python.org/pypi 下載到本地,而後解包安裝。
不過由於某些緣由,訪問官方的pypi不穩定,很慢甚至有些還時不時的訪問不了。linux
跟ubuntu的apt和centos的yum有各個鏡像源同樣,pypi也有。django
在國內的強烈推薦豆瓣的源
http://pypi.douban.com/simple/
注意後面要有/simple目錄。ubuntu
使用鏡像源很簡單,用-i指定就好了:windows
sudo easy_install -i http://pypi.douban.com/simple/ ipython sudo pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple ipython
每次都要這樣寫? no!,作個別名吧,額,相似於這樣centos
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com django
好像還不太好,腫麼辦?寫在配置文件裏吧。url
[global] timeout = 60 index-url = https://pypi.doubanio.com/simple
** 注意: **若是使用http連接,須要指定trusted-host
參數code
[global] timeout = 60 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com
linux下指定位置爲
$HOME/.config/pip/pip.conf
或者
$HOME/.pip/pip.conf
ip
mac下指定位置爲
$HOME/Library/Application Support/pip/pip.conf
或者
$HOME/.pip/pip.conf
get
windows下指定位置爲
%APPDATA%\pip\pip.ini
或者
%HOME%\pip\pip.ini