將pip源更換到國內鏡像
用pip管理工具安裝第三方庫文件時,默認使用國外的源文件,因此在國內的下載速度會比較慢,可能只有50KB/s。幸好,國內的一些頂級科研機構已經給我們准備好了各種鏡像,下載速度可達2MB/s。
其中,比較常用的國內鏡像包括:
(1)阿里雲 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
(5)華中科技大學http://pypi.hustunique.com/
注意:新版ubuntu要求使用https源。
設置方法:(以清華鏡像為例,其它鏡像同理)
(1)臨時使用:
可以在使用pip的時候,加上參數-i和鏡像地址(如
https://pypi.tuna.tsinghua.edu.cn/simple),
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,這樣就會從清華鏡像安裝pandas庫。
LINUX永久修改
(2)LINUX永久修改,一勞永逸:
(a)Linux下,修改 ~/.pip/pip.conf (沒有就創建一個文件夾及文件。文件夾要加“.”,表示是隱藏文件夾)
內容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
Windows 更換PIP國內源如下
永久修改pip源:
1.使用win+R調出運行,輸入”%appdata”,回車
2.在此文件夾中創建pip文件夾,進入pip文件夾並創建pip.ini文件
3.粘貼如下文件內容即可:
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple/
trusted-host = pypi.douban.com
(如果想修改鏡像,修改地址即可)
pip國內的一些鏡像:
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/