← Back to issue list

“ModuleNotFoundError: No module named ‘distutils.util’” when trying to build snaps on Launchpad (but works locally)

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1864589
Type
issue
State
open
Author
~pieq
Labels
—
Created
Updated
Closed
—

Current evaluation

Launchpad/bionic builds failed with 'No module named distutils.util' due to missing python3-distutils; fixed in python plugin commits cec1a111c (#2058) and d1fd9a226, still open with workarounds confirmed.

Suggested action: close resolved

Reason: The snapcraft history contains two commits that directly target this report: cec1a111c 'python plugin: install python-distutils when run on bionic (#2058)' and d1fd9a226 'python plugin: properly handle distutils on bionic', matching the reporter's proposed workaround of pulling python3-distutils. At the pinned HEAD the bionic-specific handling is gone entirely (grep for 'distutils'/'python3-distutils' matches only spread test setup.py files) because the legacy python plugin now delegates to craft_parts' PythonPlugin and core18/bionic support was dropped, so no code path remains to fix. Residual work is limited to the separately tracked error-masking symptom in snapcraft#1882124.

Evaluated by: mr-cal-bot

Impact: 35 Quick Win: 15 Complexity: 40 Confidence: 80 Actionability: 70

Issue body

This initially started as a discussion on the forum, so the whole gist of the problem is explained there: https://forum.snapcraft.io/t/modulenotfounderror-no-module-named-distutils-util-when-trying-to-build-snaps-on-launchpad-but-works-locally/15434 In a nutshell: - A snapcraft recipe can be build locally on my laptop, but fails to build on Launchpad build infrastructure due to "No module named 'distutils.util'" error. - The problem seems to be that there are some parts built before the part where it fails, pulling some python3 dependencies (but not python3-distutils) that are cached in the stage directory - When the main part is built, snapcraft tries to used cached data instead of pulling fresh one, resulting in a missing dependency Workaround In my case, cjp256 suggested to add `python3-distutils` to sosreport part `stage-packages`.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 35
Quick Win: 15
Complexity: 40
Confidence: 80
Actionability: 70
close resolved Launchpad/bionic builds failed with 'No module named distutils.util' due to missing python3-distutils; fixed in python plugin commits cec1a111c (#2058) and d1fd9a226, still open with workarounds confirmed.
stealth/space-bunny-alpha
Impact: 58
Quick Win: 29
Complexity: 40
Confidence: 94
Actionability: 82
close resolved Missing distutils broke some Launchpad Python builds; Snapcraft later added Bionic-specific handling, so the open report appears resolved by commits cec1a111c and d1fd9a226.
stealth/space-bunny-alpha
Impact: 52
Quick Win: 29
Complexity: 37
Confidence: 87
Actionability: 90
close resolved Remote Bionic/core18 builds could fail on missing distutils because staged Python dependencies were not refreshed; the Python plugin was fixed, and adding python3-distutils to stage-packages is a confirmed workaround.
stealth/space-bunny-alpha
Impact: 35
Quick Win: 7
Complexity: 55
Confidence: 58
Actionability: 45
needs triage Snapcraft fails on Launchpad with missing distutils.util, apparently from cached stage packages; adding python3-distutils to sosreport is a temporary workaround and needs investigation.
qwen/qwen3.8-27b
Impact: 30
Quick Win: 14
Staleness: 92
Complexity: 55
Confidence: 65
Support Request: 10
close stale Snapcraft Launchpad builds fail with 'No module named distutils.util' due to stage-directory caching of python3 deps; workaround (add python3-distutils to stage-packages) documented in body. Untriaged, no comments, inactive ~5 years.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 20
Confidence: 85
Support Request: 30
close stale Launchpad snap builds fail with missing distutils.util module. Workaround provided. Untriaged and inactive for over 6 years.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 15
Confidence: 90
Support Request: 20
close stale Build failure on Launchpad due to missing distutils.util module when building snaps. Provides a workaround to add python3-distutils to stage-packages. No maintainer response or labels after over 5 years of inactivity.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 15
Confidence: 90
Support Request: 70
close stale Build failure on Launchpad due to missing distutils module, caused by cached stage packages. User provided a workaround. Issue is over 6 years old with no maintainer response.

Update history

Date Change
created

Related work

  • Related To: snapcraft (launchpad)#1882124 (confidence 90%)

    Explicitly cross-referenced by ~dmitriis in a comment: the legacy python plugin hid the real traceback behind "Failed to run '/root/stage/usr/bin/python3 -m pip': Exited with code 1"; still open.

  • Likely Fixed By: canonical/snapcraft#2058 (confidence 85%)

    Commit cec1a111c 'python plugin: install python-distutils when run on bionic (#2058)', followed by d1fd9a226 'python plugin: properly handle distutils on bionic'.

Related issues

No related issues found above the similarity threshold.