使用python必然離不開pip這一強大的包管理工具.但是由於pip的官方源在國外,所以造成安裝包速度要麼特別慢或者根本就安裝不了,所以修改python源是安裝包時必備的技能
臨時使用
使用阿里源安裝requests
pip install requests -i https://mirrors.aliyun.com/pypi/simple
永久修改:
自動修改(推薦)
pip config set global.trusted-host mirrors.aliyun.com
pip config set global.index-url https://mirrors.aliyun.com/simple
手動修改
-
linux/mac (沒有就創建一個)
vi ~/.pip/pip.conf [global] trusted-host=mirrors.aliyun.com index-url=https://mirrors.aliyun.com/pypi/simple/
- windows下,直接在user目錄中創建一個pip目錄,如:C:\Users\xx-user\pip\pip.ini
[global] trusted-host=mirrors.aliyun.com index-url=https://mirrors.aliyun.com/pypi/simple/
注意:爲了一些不必要的麻煩建議把trusted-host也同步設置.
常用源:
官方 https://pypi.python.org/simple/
阿里雲
http://mirrors.aliyun.com/pypi/simple/
豆瓣
http://pypi.douban.com/simple/
清華
https://pypi.tuna.tsinghua.edu.cn/simple
個人喜好,因爲管理的服務器大多是阿里雲,所以安裝包時第一步就是先設置源爲阿里,不光因爲速度快,還因爲走的內網不花費流量喲.
that's all