Why does pipenv fail to install a package inside a docker container

  • A+
Category:Languages

Follows a Dockerfile for the sake of reproducibility:

# 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.


 


To make a summary from comments :

The Problem exists because of the check condition in the wheel.py in pip sources. To resolve this problem there is already TODO comment added to sources.

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

but for future changes there is link to first appearnce of this TODO 1st detected.

Current solution :

as OP mentioned

comment the PIP_NO_CACHE_DIR=off

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: