gpt4 book ai didi

python - 有什么方法可以强制 pip install 在需求安装失败时重试?

转载 作者:行者123 更新时间:2023-12-03 23:08:23 26 4
gpt4 key购买 nike

我正在尝试在我构建的容器中安装一些 pip 要求。但是由于我的设置(docker build 在通过 VPN 连接到 git 服务器所在网络的系统上的 VM 中运行。COVID-19 情况)我收到以下错误。我知道问题是由我的设置引起的,因为有时工作正常。另外,如果我在与 git 服务器位于同一网络内的机器上运行相同的 docker build,也可以正常工作。我花了一些时间试图找出我的网络问题,但还没有找到任何合适的解决方案。
所以知道有一段时间 pin install git clone 工作,我想知道是否有任何方法可以指示 pip 重试安装失败的组件,直到它成功?

这就是我调用 pip install 的方式:

pip install --no-cache-dir --disable-pip-version-check -r requirements.txt

git lab repo URL 在 requirements.txt 中正确定义

谢谢
Collecting git+https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git@0.0.3 (from -r requirements.txt (line 19))
Cloning https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git (to revision 0.0.3) to /tmp/pip-req-build-t8m2io14
Running command git clone -q 'https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git' /tmp/pip-req-build-t8m2io14
fatal: unable to access 'https://git.my.host.com/core-tech/tools/nlu/trsx-converter.git/': The requested URL returned error: 511
ERROR: Command errored out with exit status 128: git clone -q 'https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git' /tmp/pip-req-build-t8m2io14 Check the logs for full command output.

最佳答案

有一个 --retries pip install 上的选项命令:

pip install --help

General Otions:

--retries <retries> Maximum number of retries each connection should attempt (default 5 times).

它是 5默认情况下,所以我不确定它是否真的能解决您的问题,但您可以尝试使用更高的值,以防万一。

关于python - 有什么方法可以强制 pip install 在需求安装失败时重试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60780791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com