python pip自帶的源是國外的,pip install的時候很慢,更改爲國內的源。
1. pip國內的一些鏡像
阿里雲: http://mirrors.aliyun.com/pypi/simple/
清華大學: https://pypi.tuna.tsinghua.edu.cn/simple/
中國科技大學: https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban): http://pypi.douban.com/simple/
中國科學技術大學: http://pypi.mirrors.ustc.edu.cn/simple/
2. 修改源方法:
2.1 臨時使用:
可以在使用pip的時候在後面加上-i參數,指定pip源
eg: pip install package -i https://pypi.tuna.tsinghua.edu.cn/simple
2.2 永久修改:
linux:
修改 ~/.pip/pip.conf (沒有就創建一個), 內容如下:
-
[global]
-
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
- 1
- 2
windows:
直接在user目錄中創建一個pip目錄,如:C:\Users\xx\pip,在pip 目錄下新建文件pip.ini,內容如下
或者按照網友的建議:win+R 打開用戶目錄%HOMEPATH%,在此目錄下創建 pip 文件夾,在 pip 目錄下創建 pip.ini 文件, 內容如下
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn