天天看點

pip下載下傳速度慢-解決方法

由于pipy網站是國外網站,很容易會被牆,導緻經常下載下傳速度非常慢,經常逾時。解決方式: 更改pip的資料源。目前國内比較知名的有豆瓣的,清華的。都是pipy官網的鏡像。

修改源方法

臨時使用:

可以在使用pip的時候在後面加上-i參數,指定pip源,例如:

pip install 庫名 -i 鏡像源url #方法1
pip install -i 鏡像源url 庫名 #方法1

#例如:
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow 
           

永久修改:

linux

下:

修改

~/.pip/pip.conf

(若沒有就建立一個

vi ~/.pip/pip.conf

), 内容如下:

[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
           

pip國内的一些鏡像源

阿裡雲: https://mirrors.aliyun.com/pypi/simple/

中國科技大學: https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban): http://pypi.douban.com/simple/

清華大學: https://pypi.tuna.tsinghua.edu.cn/simple/

中國科學技術大學: http://pypi.mirrors.ustc.edu.cn/simple/

轉自:更換pip源到國内鏡像