pip安装超时“socket.timeout: The read operation timed out“

it2024-12-29  9

如下:

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

报错如下:

错误一: ERROR: Exception: ...... socket.timeout: The read operation timed out ...... File "/usr/local/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 442, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out. 错误二: 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/certifi/

解决:

设置默认的超时时间

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

豆瓣的只需要注意主机的受信问题

pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

国内的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/
最新回复(0)