一、常用的pip國内源有以下幾個:
- http://pypi.douban.com/simple/ 豆瓣
- http://mirrors.aliyun.com/pypi/simple/ 阿裡
- http://pypi.hustunique.com/simple/ 華中理工大學
- http://pypi.sdutlinux.org/simple/ 山東理工大學
- http://pypi.mirrors.ustc.edu.cn/simple/ 中國科學技術大學
- https://pypi.tuna.tsinghua.edu.cn/simple 清華大學
二、換源方式:
1.臨時換源:
pip install SomePackage -i SomeSource
2.長期換源:
2.1.配置檔案位置
2.1.1.Linux
- /etc/pip.conf
- ~/.pip/pip.conf
- ~/.config/.pip/pip.conf
2.1.2.MacOS
- ~/Library/Application Support/.pip/pip.conf
- ~/.pip/pip.conf
- /Library/Application Support/.pip/pip.con
2.1.3Windows
- %APPDATA%\pip\pip.ini
- %HOME%\.pip\pip.ini
- C:\Documents and Settings\All Users\Application Data\PyPA\.pip\pip.conf (Windows XP)
- C:\ProgramData\PyPA\.pip\pip.conf (Windows 7及以後)
2.2配置檔案内容
[global]
#豆瓣源,可以換成其他的源
index-url = http://pypi.douban.com/simple
#添加豆瓣源為可信主機,要不然可能報錯
trusted-host = pypi.douban.com
#取消pip版本檢查,排除每次都報最新的pip
disable-pip-version-check = true
#逾時
timeout = 120
三、參考
- https://blog.csdn.net/testcs_dn/article/details/54374849
- https://blog.csdn.net/permike/article/details/51068916