vscode使用pip安装django超时
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.
原因:网络原因导致下载超时
pip3默认的下载源是https://pypi.org/simple
Base URL of the Python Package Index (default https://pypi.org/simple).
This should point to a repository compliant with PEP 503
(the simple repository API) or a local directory laid out in the same format.
解决办法:指定国内或者其他的下载源
切换镜像源:
豆瓣:http://pypi.douban.com/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
山东理工大学:http://pypi.sdutlinux.org/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中科技大学:http://pypi.hustunique.com/
因此命令可以改为:
pip3 install django -f https://download.pytorch.org/whl/cu113/torch_stable.html \
-i https://pypi.tuna.tsinghua.edu.cn/simple
大牛提供的方法
如果你的网速一直很拉闸,上面的方法依然解决不了,那这时可以使用如下的解决方案:
pip --default-timeout=1688 install 库名称 \
-i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
那在这里可以分别用该方法安装torch和torchvision
也就是使用命令:
pip3 --default-timeout=1688 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 \
-f https://download.pytorch.org/whl/cu113/torch_stable.html \
-i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
这里的–default-timeout=1688其实意思就是让其检测延迟的时间变长,以防止因为你的网络问题而直接报错