讓PIP源使用國內鏡像,提高下載速度和安裝成功率。

 
 

對於Python開發用戶來說,PIP安裝軟件包是屢見不鮮。但國外的源下載速度實在太慢,浪費時間。並且常常出現下載後安裝出錯問題。因此把PIP安裝源替換成國內鏡像,能夠大幅提高下載速度,還能夠提升安裝成功率。python

國內源:

新版ubuntu要求使用https源,要注意。linux

清華:https://pypi.tuna.tsinghua.edu.cn/simpleubuntu

阿里雲:http://mirrors.aliyun.com/pypi/simple/windows

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

華中理工大學:http://pypi.hustunique.com/ide

山東理工大學:http://pypi.sdutlinux.org/ 阿里雲

豆瓣:http://pypi.douban.com/simple/url

臨時使用:

能夠在使用pip的時候加參數-i https://pypi.tuna.tsinghua.edu.cn/simplespa

 

 

永久修改,一勞永逸:

Linux下,修改 ~/.pip/pip.conf (沒有就建立一個文件夾及文件。文件夾要加「.」,表示是隱藏文件夾)code



例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,這樣就會從清華這邊的鏡像去安裝pyspider庫。

 

內容以下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host=mirrors.aliyun.com

windows下

找到你python的安裝目錄下的文件

注意虛擬環境的話還須要改虛擬環境裏的index.py

例如個人D:\soft\PY\Lib\site-packages\pip_internal\models下面的index.py文件裏面將PYPI的值改成你所須要的源便可,例如改成清華的源。PyPI = PackageIndex(‘https://pypi.tuna.tsinghua.edu.cn/simple’, file_storage_domain=‘files.pythonhosted.org’)保存文件便可.

相關文章
相關標籤/搜索