I recently updated to Ubuntu Noble, which ships with externally managed python 3.12. I tried following the install instructions for docker-pkg (which worked fine in ubuntu jammy + python 3.10), but got:
~/Git/docker-pkg (master) $ pip3 install --local -e .
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
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.
hint: See PEP 668 for the detailed specification.On its own this wouldn't be a huge deal: docker-pkg can be installed with pipx, so it would be just an update to the instructions. However:
$ pipx install -e . installed package docker_pkg 4.0.2, installed using Python 3.12.3 These apps are now globally available - docker-pkg done! ✨ 🌟 ✨ $ docker-pkg --version Traceback (most recent call last): File "/home/username/.local/bin/docker-pkg", line 5, in <module> from docker_pkg.cli import main File "/home/username/Git/docker-pkg/docker_pkg/cli.py", line 13, in <module> from docker_pkg import builder, dockerfile, image File "/home/username/Git/docker-pkg/docker_pkg/builder.py", line 10, in <module> import docker File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/__init__.py", line 2, in <module> from .api import APIClient File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/api/__init__.py", line 2, in <module> from .client import APIClient File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/api/client.py", line 10, in <module> from .. import auth File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/auth.py", line 5, in <module> from . import credentials File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/credentials/__init__.py", line 2, in <module> from .store import Store File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/credentials/store.py", line 7, in <module> from .utils import create_environment_dict File "/home/username/.local/share/pipx/venvs/docker-pkg/lib/python3.12/site-packages/docker/credentials/utils.py", line 1, in <module> import distutils.spawn ModuleNotFoundError: No module named 'distutils'
(NB: I later found out that there's no --version, but that doesn't make any difference)
I found https://stackoverflow.com/a/76691103 mentioning (see link to release notes) that distutils has been removed from the standard library in python 3.12. setuptools can be used as a replacement, but it is not automatically available. The usage in docker-py has been removed in commit 42789818bed5d86b487a030e2e60b02bf0cfa284, but that's included in docker-py 6+, whereas docker-pkg has a requirement of "docker >=5.0.0, <6.0.0". So, either this requirement is bumped, or setuptools needs to be added to the list of requirements (which I can confirm fixes the issue).