天天看點

解決pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

場景

在用Dockerfile制作鏡像的時候總是出現如下錯誤

解決pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

原因分析

在下載下傳python庫的時候,由于國内網絡原因,python包的下載下傳速度非常慢,檢視pip 文檔,隻要在 pip的時候控制逾時即可, 具體參數為 --default-timeout=100, 後面的時間可以自己指定。

解決

pip install --default-timeout=1000 --no-cache-dir -r requirements.txt