pip換源
阿新 • • 發佈:2020-07-16
一:引言
在用pip命令安裝時,有時候會出現這樣的報錯
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool
(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out. (read timeout=15)")': /simple/asn1crypto/
這是因為預設的pip源是在國外的,連線錯誤或者丟包了,這時候就需要更換pip源了
二:pip源
1.在國內的pip源有以下幾個:
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
三:一次性使用
1.使用格式:
pip install [要安裝的] -i [pip源] --trusted-host [pip源https://之後,/simple/之前的內容]
2.比如說:要用阿里雲的pip源安裝django
pip install django -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pip install django -i https://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host pypi.mirrors.ustc.edu.cn pip install django -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com pip install django -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn pip install django -i http://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host pypi.mirrors.ustc.edu.cn
四:永久使用
1.開啟檔案管理器,在路徑位址列輸入%APPDATA%
2.此時會進入C:\Users\電腦使用者\AppData\Roaming
資料夾中,新建一個資料夾,命名為pip
3.進入pip
資料夾,新建一個文字文件,重新命名為pip.ini
,右鍵 - 編輯
4.輸入下列程式碼,然後儲存,關閉
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com