pipenv
pipenv copied to clipboard
Install pipenv failed in alpine 3.13 with 'distlib' package dependency error
Issue description
I have a project is using python 3.8 and run at alpine 3.13 by docker. On each release it builds a new docker image and packages like python, pip, pipenv etc will be installed during docker build.
This flow was working fine before, but these days, the docker build fails due to an error when installing pipenv. It looks like the "distlib" package used by pipenv has been upgraded to the new version (0.3.5), but pip is still using the old version (0.3.1). Then pipenv tries to upgrade the "distlib" version installed by pip, but it get a distutils install error.
Expected result
Install success
Actual result
Docker build logs The step of build is:
- install python3
- install py3-pip
- install pipenv
Step 1/8 : ARG ALPINE_VER=3.13
Step 2/8 : FROM alpine:$ALPINE_VER
3.13: Pulling from library/alpine
627fad6f28f7: Pulling fs layer
627fad6f28f7: Verifying Checksum
627fad6f28f7: Download complete
627fad6f28f7: Pull complete
Digest: sha256:7769c38ce671534a0ddbf98633f17edbbd4a4e99cbc77ef42f9f7b78b6a1c6c2
Status: Downloaded newer image for alpine:3.13
---> 38cacb9bafd2
Step 3/8 : RUN apk add --no-cache python3
---> Running in 75a1b197a031
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/10) Installing libbz2 (1.0.8-r1)
(2/10) Installing expat (2.2.10-r6)
(3/10) Installing libffi (3.3-r2)
(4/10) Installing gdbm (1.19-r0)
(5/10) Installing xz-libs (5.2.5-r1)
(6/10) Installing ncurses-terminfo-base (6.2_p20210109-r1)
(7/10) Installing ncurses-libs (6.2_p20210109-r1)
(8/10) Installing readline (8.1.0-r0)
(9/10) Installing sqlite-libs (3.34.1-r0)
(10/10) Installing python3 (3.8.10-r0)
Executing busybox-1.32.1-r9.trigger
OK: 53 MiB in 24 packages
Removing intermediate container 75a1b197a031
---> 93ffca869589
Step 4/8 : RUN apk add --no-cache py3-pip
---> Running in 28b01d18c444
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/25) Installing py3-appdirs (1.4.4-r1)
(2/25) Installing py3-ordered-set (4.0.2-r0)
(3/25) Installing py3-parsing (2.4.7-r1)
(4/25) Installing py3-six (1.15.0-r0)
(5/25) Installing py3-packaging (20.9-r0)
(6/25) Installing py3-setuptools (51.3.3-r0)
(7/25) Installing py3-chardet (4.0.0-r0)
(8/25) Installing py3-idna (3.1-r0)
(9/25) Installing py3-urllib3 (1.26.2-r1)
(10/25) Installing py3-requests (2.25.1-r1)
(11/25) Installing py3-msgpack (1.0.2-r0)
(12/25) Installing py3-lockfile (0.12.2-r3)
(13/25) Installing py3-cachecontrol (0.12.6-r0)
(14/25) Installing py3-colorama (0.4.4-r0)
(15/25) Installing py3-contextlib2 (0.6.0-r0)
(16/25) Installing py3-distlib (0.3.1-r1)
(17/25) Installing py3-distro (1.5.0-r1)
(18/25) Installing py3-webencodings (0.5.1-r3)
(19/25) Installing py3-html5lib (1.1-r0)
(20/25) Installing py3-pytoml (0.1.21-r0)
(21/25) Installing py3-pep517 (0.9.1-r0)
(22/25) Installing py3-progress (1.5-r0)
(23/25) Installing py3-retrying (1.3.3-r0)
(24/25) Installing py3-toml (0.10.2-r0)
(25/25) Installing py3-pip (20.3.4-r0)
Executing busybox-1.32.1-r9.trigger
OK: 75 MiB in 49 packages
Removing intermediate container 28b01d18c444
---> 982205860810
Step 5/8 : RUN pip3 install --no-cache-dir --upgrade pipenv
---> Running in de57d96d5e69
Collecting pipenv
Downloading pipenv-2022.8.5-py2.py3-none-any.whl (3.5 MB)
Requirement already satisfied: setuptools>=36.2.1 in /usr/lib/python3.8/site-packages (from pipenv) (51.3.3)
Collecting virtualenv-clone>=0.2.5
Downloading virtualenv_clone-0.5.7-py3-none-any.whl (6.6 kB)
Collecting certifi
Downloading certifi-2022.6.15-py3-none-any.whl ([160](https://qif-gitlab.dev-myqnapcloud.com/amiz-cloud/amiz/-/jobs/287367#L160) kB)
Collecting virtualenv
Downloading virtualenv-20.16.3-py2.py3-none-any.whl (8.8 MB)
Collecting distlib<1,>=0.3.5
Downloading distlib-0.3.5-py2.py3-none-any.whl (466 kB)
Collecting platformdirs<3,>=2.4
Downloading platformdirs-2.5.2-py3-none-any.whl (14 kB)
Collecting filelock<4,>=3.4.1
Downloading filelock-3.7.1-py3-none-any.whl (10 kB)
Installing collected packages: platformdirs, filelock, distlib, virtualenv-clone, virtualenv, certifi, pipenv
Attempting uninstall: distlib
Found existing installation: distlib 0.3.1
ERROR: Cannot uninstall 'distlib'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
The command '/bin/sh -c pip3 install --no-cache-dir --upgrade pipenv' returned a non-zero code: 1
Steps to replicate
Try to build image with a simple Dockerfile
ARG ALPINE_VER=3.13
FROM alpine:$ALPINE_VER
RUN apk add --no-cache python3
RUN apk add --no-cache py3-pip
RUN pip3 install --no-cache-dir --upgrade pipenv
@Winedays I tried it out and it seems the issue is with py3-pip -- I replaced that part of the Dockerfile with the get-pip script and it worked:
ARG ALPINE_VER=3.13
FROM alpine:$ALPINE_VER
RUN apk add --no-cache python3
RUN apk add --no-cache wget
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py
RUN pip3 install --no-cache-dir --upgrade pipenv
@matteius It works for install pip using the get-pip script. So this is a problem with the alpine package manager, thanks for the commented.