使用pip install 安裝python第三方庫時出現了如下錯誤:
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.
原因分析:
使用pip下載python第三方庫時,由於國內網絡的限制,下載速度緩慢,而超過一定時長時,就默認下載失敗。
解決方法:
1:延長超時時間
pip3 install --default-timeout=1000 "包的名稱"
2:更改下載源
由於默認的國外下載源下載速度十分緩慢,所以可以選擇國內的幾個比較好的鏡像
阿里雲 http://mirrors.aliyun.com/pypi/simple/ 中國科技大學 https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/ 豆瓣 http://pypi.doubanio.com/simple/ 清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
使用命令:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 庫名