luffy之pip換源
阿新 • • 發佈:2020-12-21
一、pip換源
在用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源了
1.1 pip源
1.在國內的pip源有以下幾個:
阿里雲 http://mirrors.aliyun.com/pypi/simple/ 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/ 中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
2.一次性使用
2.1使用格式
pip install [要安裝的] -i [pip源] --trusted-host [pip源https://之後,/simple/之前的內容]
2.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.compip 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
3. 永久使用
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