alpinelinux / docker-alpine

Official Alpine Linux Docker image. Win at minimalism!
MIT License
1.04k stars 261 forks source link

3.19.0 doesnt correctly install pip #361

Closed billdinger closed 6 months ago

billdinger commented 6 months ago

Good evening. The newest pushed 3.19.0 docker image has some issue (Still digging, will update) with pip.

docker run -it alpine:3.19.0
apk update && apk add py3-pip
pip install <>

Results in:

error: externally-managed-environment

× This environment is externally managed
╰─> 
    The system-wide python installation should be maintained using the system
    package manager (apk) only.

    If the package in question is not packaged already (and hence installable via
    "apk add py3-somepackage"), please consider installing it inside a virtual
    environment, e.g.:

    python3 -m venv /path/to/venv
    . /path/to/venv/bin/activate
    pip install mypackage

    To exit the virtual environment, run:

    deactivate

    The virtual environment is not deleted, and can be re-entered by re-sourcing
    the activate file.

    To automatically manage virtual environments, consider using pipx (from the
    pipx package).

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

The pip version is different from alpine 3.18.0: 3.18.0:

/ # pip3 --version
pip 23.1.2 from /usr/lib/python3.11/site-packages/pip (python 3.11

3.19.0:

pip 23.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
billdinger commented 6 months ago

looks like this is actually intended functionality https://gitlab.alpinelinux.org/alpine/aports/-/issues/14617 so not a bug, just a change to enforce https://peps.python.org/pep-0668/#keep-the-marker-file-in-container-images

Going to close this; as given workaround in issue in gitlab (python3 -m venv --system-site-packages /usr/local) does work as one of hte options. Have fun updating dockerfiles everyone!

billdinger commented 6 months ago

https://peps.python.org/pep-0668/#keep-the-marker-file-in-container-images

Enforcing, intended behavior https://gitlab.alpinelinux.org/alpine/aports/-/issues/14617