國(guó)內(nèi)訪問Python pip官方鏡像源速度非常慢涩维,matplotlib下載速度只有10KB/s殃姓,而且下載沒一會(huì)兒還連接超時(shí)。浪費(fèi)時(shí)間不止瓦阐,幾次下載沒有一次成功過蜗侈。
最好的解決辦法就是給pip增加國(guó)內(nèi)鏡像源。按照下面步驟設(shè)置好后睡蟋,matplotlib下載有超百倍提升踏幻,從15KB/s提升到3.6MB/s。體積比較小的庫下載速度實(shí)測(cè)滿速戳杀。
先拿Mac OSX來詳細(xì)說该面,終端進(jìn)入目錄:
$ cd ~/
如果沒有.pip這個(gè)文件夾,那么就手動(dòng)新建這個(gè)文件夾
$ mkdir .pip
然后進(jìn)入.pip信卡,在文件夾內(nèi)新建一個(gè)文件
$ cd .pip
$ touch pip.conf
編輯 pip.conf 文件隔缀,寫入阿里云鏡像源
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
同樣可以選擇豆瓣鏡像源
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
其他系統(tǒng)pip.conf保存位置
Linux/Unix:
~/.pip/pip.conf
Windows:
%APPDATA%\pip\pip.ini
%HOME%\pip\pip.ini
C:\Documents and Settings\All Users\Application Data\PyPA\pip\pip.conf (For Windows XP)
C:\ProgramData\PyPA\pip\pip.conf (For Windows 7)
其他鏡像源:
- 華中理工大學(xué) http://pypi.hustunique.com/
- 山東理工大學(xué) http://pypi.sdutlinux.org/
- 中國(guó)科學(xué)技術(shù)大學(xué) http://pypi.mirrors.ustc.edu.cn/