[英]Why does pipenv fail to install a package inside a docker container
Follows a Dockerfile for the sake of reproducibility: 为了重现性,请遵循Dockerfile:
# Dockerfile
FROM ubuntu:16.04
# pipenv install numpy pybind11 mako pyopencl
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
PIPENV_HIDE_EMOJIS=true \
PIPENV_COLORBLIND=true \
PIPENV_NOSPIN=true \
PYTHONPATH=/app \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
DEBIAN_FRONTEND=noninteractive
WORKDIR ${PYTHONPATH}
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-pip && \
rm -rf /var/lib/apt/lists/*
RUN pip3 install pipenv
Which can be built with: 哪个可以用:
docker build -f Dockerfile -t pipenv_issue .
And run with: 并运行:
docker run --rm -it pipenv_issue:latest bash
Inside which you can try: 你可以尝试在其中:
pipenv install numpy
Which will fail with: 哪个会失败:
Creating a virtualenv for this project…
Pipfile: /app/Pipfile
Using /usr/bin/python3 (3.5.2) to create virtualenv…
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /root/.local/share/virtualenvs/app-4PlAip0Q/bin/python3
Also creating executable in /root/.local/share/virtualenvs/app-4PlAip0Q/bin/python
Installing setuptools, pip, wheel...
done.
Virtualenv location: /root/.local/share/virtualenvs/app-4PlAip0Q
Creating a Pipfile for this project…
Installing numpy…
Adding numpy to Pipfile's [packages]…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (5a67c1)!
Installing dependencies from Pipfile.lock (5a67c1)…
An error occurred while installing numpy==1.16.0 --hash=sha256:00a458d6821b1e87be873f2126d5646b901047a7480e8ae9773ecf214f0e19f3 --hash=sha256:0470c5dc32212a08ebc2405f32e8ceb9a5b1c8ac61a2daf9835ec0856a220495 --hash=sha256:24a9c287a4a1c427c2d45bf7c4fc6180c52a08fa0990d4c94e4c86a9b1e23ba5 --hash=sha256:25600e8901012180a1b7cd1ac3e27e7793586ecd432383191929ac2edf37ff5d --hash=sha256:2d279bd99329e72c30937bdef82b6dc7779c7607c5a379bab1bf76be1f4c1422 --hash=sha256:32af2bcf4bb7631dac19736a6e092ec9715e770dcaa1f85fcd99dec5040b2a4d --hash=sha256:3e90a9fce378114b6c2fc01fff7423300515c7b54b7cc71b02a22bc0bd7dfdd8 --hash=sha256:5774d49516c37fd3fc1f232e033d2b152f3323ca4c7bfefd7277e4c67f3c08b4 --hash=sha256:64ff21aac30d40c20ba994c94a08d439b8ced3b9c704af897e9e4ba09d10e62c --hash=sha256:803b2af862dcad6c11231ea3cd1015d1293efd6c87088be33d713a9b23e9e419 --hash=sha256:95c830b09626508f7808ce7f1344fb98068e63143e6050e5dc3063142fc60007 --hash=sha256:96e49a0c82b4e3130093002f625545104037c2d25866fa2e0c90d6e54f5a1fbc --hash=sha256:a1dd8221f0e69038748f47b8bb3248d0b9ecdf13fe837440951c3d5ff72639bb --hash=sha256:a80ecac5664f420556a725a5646f2d1c60a7c0489d68a38b5056393e949e27ac --hash=sha256:b19a47ff1bd2fca0cacdfa830c967746764c32dca6a0c0328d9c893f4bfe2f6b --hash=sha256:be43df2c563e264b38e3318574d80fc8f365df3fb745270934d2dbe54e006f41 --hash=sha256:c40cb17188f6ae3c5b6efc6f0fd43a7ddd219b7807fe179e71027849a9b91afc --hash=sha256:c6251e0f0ecac53ba2b99d9f0cc16fa9021914a78869c38213c436ba343641f0 --hash=sha256:cb189bd98b2e7ac02df389b6212846ab20661f4bafe16b5a70a6f1728c1cc7cb --hash=sha256:ef4ae41add536cb825d8aa029c15ef510aead06ea5b68daea64f0b9ecbff17db --hash=sha256:f00a2c21f60284e024bba351875f3501c6d5817d64997a0afe4f4355161a8889 --hash=sha256:f1232f98a6bbd6d1678249f94028bccc541bbc306aa5c4e1471a881b0e5a3409 --hash=sha256:fea682f6ddc09517df0e6d5caad9613c6d91a42232aeb082df67e4d205de19cc! Will try again.
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]: skip_lock=skip_lock,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]: retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]: _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting numpy==1.16.0 (from -r /tmp/pipenv-6etsbc3u-requirements/pipenv-rs8asrue-requirement.txt (line 1))', ' Downloading https://files.pythonhosted.org/packages/64/24/2e9c72f44cec8c872000d78c54230e40550c494647e352d1d06724cdaee6/numpy-1.16.0-cp35-cp35m-manylinux1_x86_64.whl (17.2MB)']
[pipenv.exceptions.InstallError]: ['Exception:', 'Traceback (most recent call last):', ' File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.5/site-packages/pip/_internal/cli/base_command.py", line 176, in main', ' status = self.run(options, args)', ' File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.5/site-packages/pip/_internal/commands/install.py", line 346, in run', ' session=session, autobuilding=True', ' File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.5/site-packages/pip/_internal/wheel.py", line 848, in build', ' assert building_is_possible', 'AssertionError']
ERROR: ERROR: Package installation failed...
Why does it fail? 为什么会失败?
Thanks in advance. 提前致谢。
The behavior was a bug and should be fixed by upgrading to pip v19.0.1 该行为是一个错误,应通过升级到pip v19.0.1来解决
https://github.com/pypa/pip/issues/6158#issuecomment-456814568 https://github.com/pypa/pip/issues/6158#issuecomment-456814568
The Problem exists because of the check condition in the wheel.py
in pip
sources. 问题的存在是因为
pip
源中wheel.py
的检查条件。 To resolve this problem there is already TODO
comment added to sources. 要解决此问题,已向源添加了
TODO
注释。
TODO: This check fails if --no-cache-dir is set.
And yet we might be able to build into the ephemeral cache, surely?
Linkt at master provided intsco Link的主人提供了intsco
but for future changes there is link to first appearnce of this TODO 1st detected . 但是对于未来的变化,这个TODO 1st的第一次出现有链接。
as OP mentioned 如OP提到的那样
comment the PIP_NO_CACHE_DIR=off
评论
PIP_NO_CACHE_DIR=off
I had a similar problem during a build today. 我今天在构建期间遇到了类似的问题。 In my Dockerfile, which has python and pip preinstalled (I'm using
python:3.6-slim-jessie
docker image) I have the line pip install --upgrade setuptools pip
and today my build failed because of the new version upgrade. 在我的Dockerfile中,预装了python和pip(我正在使用
python:3.6-slim-jessie
docker image)我有行pip install --upgrade setuptools pip
,今天我的构建因新版本升级而失败。
My Solution: 我的解决方案
I commented the line pip install --upgrade setuptools pip
in my Dockerfile. 我评论了我的Dockerfile中的行
pip install --upgrade setuptools pip
。
Works fine now. 现在工作正常。
In your case, this problem occurs when virtualenv is created. 在您的情况下,创建virtualenv时会出现此问题。 During creation, it installs the latest versions of setuptools, pip, wheel (see the line:
Installing setuptools, pip, wheel...done.
). 在创建过程中,它会安装最新版本的setuptools,pip,wheel(参见
Installing setuptools, pip, wheel...done.
: Installing setuptools, pip, wheel...done.
)。 Downgrading to previous pip, wheel, setuptools versions will help. 降级到之前的pip,wheel,setuptools版本将有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.