[SRU] Python docker package does not import, crashes due to urllib3 upgrade
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-docker (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
In Progress
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
python3-docker is completely unusable. It will fail immediately when the user tries to import the module to use it.
$ python3
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
from .api import APIClient
File "/usr/lib/
from .client import APIClient
File "/usr/lib/
from .. import auth
File "/usr/lib/
from . import credentials
File "/usr/lib/
from .store import Store
File "/usr/lib/
from .utils import create_
File "/usr/lib/
import distutils.spawn
ModuleNotFoundE
[ Test Plan ]
Install python3-docker and docker.io
In the python3 prompt, use the following commands to test:
>>> import docker
>>> client = docker.from_env()
>>> client.
With the fixed package it will print:
b'hello world\n'
[ Where problems could occur ]
This change is a combination of two upstream patches which removes the use of disutils. The change for 'find_executable' which is replaced with 'shutil.which' should not have any regression as long as the PATH is defined properly.
The other fix for distutil changes the way 'version' is calculated for comparison and is using 'packaging.version' for it. A new runtime dependency had to be added for it. This change can cause problem if the version comparison is not as expected. But considering the fact the python3-docker is unusable now, the user should not see any new regression than what already exists.
[ Other Info ]
1. This has been fixed in Debian and so Oracular is also fixed.
2. As mentioned in the previous section, this change is a combination of two different upstream patches. The upstream patch also has changes in requirements.txt and setup.py which has been omitted in this change.
[ Original Bug Description ]
This is on a fresh install of the 24.04 beta that was released on April 12. I used the Desktop installer, into a VMware Fusion VM, on amd64.
Other than the defaults for a fresh Ubuntu Desktop install, all I ran was `apt install -y docker.io python3-docker`.
I ran `python3`, tried to execute `import docker`, and got this:
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
from .api import APIClient
File "/usr/lib/
from .client import APIClient
File "/usr/lib/
from .. import auth
File "/usr/lib/
from . import credentials
File "/usr/lib/
from .store import Store
File "/usr/lib/
from .utils import create_
File "/usr/lib/
import distutils.spawn
ModuleNotFoundE
ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: python3-docker 5.0.3-1ubuntu1
ProcVersionSign
Uname: Linux 6.8.0-22-generic x86_64
ApportVersion: 2.28.0-0ubuntu1
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: ubuntu:GNOME
Date: Tue Apr 16 16:35:20 2024
InstallationDate: Installed on 2024-04-16 (0 days ago)
InstallationMedia: Ubuntu 24.04 LTS "Noble Numbat" - Beta amd64 (20240410.2)
PackageArchitec
ProcEnviron:
LANG=en_US.UTF-8
PATH=(custom, no user)
SHELL=/bin/bash
TERM=xterm-
XDG_RUNTIME_
SourcePackage: python-docker
UpgradeStatus: No upgrade log present (probably fresh install)
tags: | added: regression-release |
summary: |
- Python docker page does not import: No module named 'distutils' + Python docker package does not import: No module named 'distutils' |
tags: | removed: wayland-session |
description: | updated |
Changed in python-docker (Ubuntu): | |
status: | Confirmed → In Progress |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in python-docker (Ubuntu Noble): | |
status: | New → In Progress |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in python-docker (Ubuntu): | |
assignee: | Sudip Mukherjee (sudipmuk) → nobody |
status: | In Progress → Fix Released |
summary: |
- Python docker package does not import, crashes due to urllib3 upgrade + [SRU] Python docker package does not import, crashes due to urllib3 + upgrade |
description: | updated |
I've been doing some checking, and it looks like this is because Python 3.12 (the default python3) no longer includes distutils. See https:/ /docs.python. org/3.12/ whatsnew/ 3.12.html (the first paragraph under the heading "Summary – Release highlights"), as well as PEP-0632 (https:/ /peps.python. org/pep- 0632/).
I figured this out when I tried downgrading the package to the version in Mantic (5.0.3-1ubuntu1): `dpkg` complained that it depends on `python3- distutils` . That led me to searching for the package in Noble, and getting to this point.
(Adding the `regression- release` tag. Apologies if this is the wrong regression tag to apply!)
BTW, this isn't affecting Debian 12 because they're using Python 3.11, the last Python version to include distutils in the standard library. Debian sid is currently on Python 3.11.8, so they haven't hit this issue yet.
As for upstream, looking at PyPi (https:/ /pypi.org/ project/ docker/ #history), 5.0.3 was the last of the 5.x series. Their latest versions are 6.1.3 and 7.0.0. Their changelog page (https:/ /docker- py.readthedocs. io/en/stable/ change- log.html) does not explicitly say when they moved away from distutils, but from Git commits it looks like the removal happened in https:/ /github. com/docker/ docker- py/commit/ 42789818bed5d86 b487a030e2e60b0 2bf0cfa284, which was included in the 6.0.0 and later releases.
So, what to do in the meantime? According to PEP-0632, Setuptools adopted distutils, and this started to happen in Setuptools 48 (https:/ /github. com/pypa/ setuptools/ issues/ 417#issuecommen t-653593796). Since the python3-setuptools package in Noble is newer (68.1.2-2ubuntu1), probably the best workaround is for `python3-docker` to depend on `python3- setuptools` .
== Regression details == 5.0.3-1ubuntu1
Discovered in version:
Last known good version:5.0.3-1