docker-library / python

Docker Official Image packaging for Python

Home Page:https://www.python.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible use of system python packages for alpine?

mmacata opened this issue · comments

I stumpled over different python versions in my Dockerfile based on python:3-alpine3.19, found the related (closed) issues here and also the explanaition.

In the past we often installed python packages via distro package manager when available. After implementation of PEP 668 – Marking Python base environments as “externally managed” and switching from basic alpine to this dockerimage, I found that I cannot use the python modules installed from distro package manager with the default python version.

Now I would be greatful for some advise - what is the best practise here? Switching all installations back to Python-specific package manager again?

As you've deduced, but to state explicitly: if you want to use distribution Python packages, this is definitely not the image to use (this is an image that installs Python from source, and thus modules need to be installed in the same / native ways, like pip install, and distribution packages are going to install a second version of Python at best and cause conflicts/errors at worst).

I think the biggest use case for this image over distro packages is going to be if you're particular about your Python versions (we support every version Python upstream does, and aggressively update when upstream does new releases). Unfortunately there's not a clear-cut "better" solution between the two that I could recommend -- each use case and deployment is going to be a little different.

Thanks for clarification!