使用國內鏡像源來加速python pypi包的安裝

默認pip是使用Python官方的源,可是因爲國外官方源常常被牆,致使不可用,咱們能夠使用國內的python鏡像源,從而解決Python安裝不上庫的煩惱。python

網上有不少可用的源,例如:
豆瓣:http://pypi.douban.com/simple/
清華:https://pypi.tuna.tsinghua.edu.cn/simple

注意後面要有/simple目錄!!! windows

 

 

一、臨時使用,只有安裝pillow時使用指定源bash

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow

 

二、永久修改,一勞永逸url

Linux下,修改 ~/.pip/pip.conf (沒有就建立一個), 修改 index-url至tuna,內容以下:
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
 
windows下,直接在user目錄中建立一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容以下:
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
相關文章
相關標籤/搜索