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

标签 python git pip gitlab

我正在尝试在我构建的容器中安装一些 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/

相关文章:

git - 如何打印自分支创建以来所有提交者的列表

ruby-on-rails - 从 Git 重新开始

pip - Ansible 使用最新版本的 setuptools 和 pip 获取 virtualenv 的正确方法

python - pip安装pyaudio错误cl.exe失败

python-3.x - 每当我在 CMD 中运行 pip -V 时,Windows 就会崩溃

git - 将 big bzr 存储库转换为 git,会发生什么?

python - PyVisa 读取超时

python - 在 tensorflow 中读取大型数据集

python - mkvtoolnix批量删除音轨

python - 如何在 python 中使用 glob 指定目录?