在 docker 构建期间,Poetry 安装失败,并出现 CalledProcessError 和 EnvCommandError

Vis*_*sio 5 pypi docker python-poetry

问题总结

我一直在尝试构建一个使用诗歌命令安装依赖项的 docker 映像RUN poetry install
我将其作为docker buildGitLab CI/CD 管道工作的一部分,在自己的运行器 VM 实例上运行它。但是,docker 构建过程在使用 运行
期间反复崩溃,然后在处理此错误期间使用和错误。 下面是一些错误示例:poetry installCalledProcessErrorEnvCommandErrorPoetryException

 CalledProcessError
 Command '['/home/ray/anaconda3/bin/python', '/home/ray/anaconda3/lib/python3.9/site-packages/virtualenv/seed/wheels/embed/pip-22.0.4-py3-none-any.whl/pip', 'install', '--disable-pip-version-check', '--prefix', '/home/ray/anaconda3', '--no-deps', '/home/ray/.cache/pypoetry/artifacts/a8/b9/10/d38e9304d486f9398ab4163054bd6af79c74073ad8685d6cc67f88eccc/Werkzeug-2.2.2-py3-none-any.whl']' returned non-zero exit status 1.
Run Code Online (Sandbox Code Playgroud)

然后

EnvCommandError
Command ['/home/ray/anaconda3/bin/python', '/home/ray/anaconda3/lib/python3.9/site-packages/virtualenv/seed/wheels/embed/pip-22.0.4-py3-none-any.whl/pip', 'install', '--disable-pip-version-check', '--prefix', '/home/ray/anaconda3', '--no-deps', '/home/ray/.cache/pypoetry/artifacts/a8/b9/10/d38e9304d486f9398ab4163054bd6af79c74073ad8685d6cc67f88eccc/Werkzeug-2.2.2-py3-none-any.whl'] errored with the following return code 1, and output: 
WARNING: Ignoring invalid distribution -irtualenv (/home/ray/anaconda3/lib/python3.9/site-packages)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/ray/anaconda3/lib/python3.9/site-packages/virtualenv/seed/wheels/embed/pip-22.0.4-py3-none-any.whl'
Run Code Online (Sandbox Code Playgroud)

然后还PoetryException报错:

PoetryException
Failed to install /home/ray/.cache/pypoetry/artifacts/a8/b9/10/d38e9304d486f9398ab4163054bd6af79c74073ad8685d6cc67f88eccc/Werkzeug-2.2.2-py3-none-any.whl
at anaconda3/lib/python3.9/site-packages/poetry/utils/pip.py:55 in pip_install
Run Code Online (Sandbox Code Playgroud)

Werkzeug-2.2.2(上面列出的)和torch-1.11.0(未列出以节省空间)会发生相同的一系列错误。

尝试解决

我尝试了以下操作但没有成功:

  • 通过将命令添加到我的 docker 文件或在构建 docker 映像之前按照此处所述清理 PyPI 缓存。pip cache purge
  • 我想以某种方式遵循此处描述的快速修复的建议。然而,我无法找到那些文物。所以我不明白如何删除它们。/home/ray/.cache/pypoetry/artifacts/a8/b9/10/d38e9304d486f9398ab4163054bd6af79c74073ad8685d6cc67f88eccc/Werkzeug-2.2.2-py3-none-any.whl

如果需要,我可以共享 docker 文件。

我将不胜感激任何帮助!

Ale*_*ion 2

RUN pip install -U pip virtualenv
Run Code Online (Sandbox Code Playgroud)

Poetrypip在启动时从virtualenv带有virtualenv.seed.wheels.embed.get_embed_wheel. 看起来可以在运行virtualenv时更新,并且该路径变得无效。poetry install