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

Bug #1864589 reported by Pierre Equoy
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Snapcraft
Confirmed
Undecided
Chris Patterson

Bug Description

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`.

Chris Patterson (cjp256)
Changed in snapcraft:
status: New → Confirmed
assignee: nobody → Chris Patterson (cjp256)
Revision history for this message
Pierre Equoy (pieq) wrote :
Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Also encountered this while building using multipass.

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Also note that you might encounter just this message on subsequent runs which hides the real issue:

Failed to run '/root/stage/usr/bin/python3 -m pip': Exited with code 1.

See https://bugs.launchpad.net/snapcraft/+bug/1882124

Revision history for this message
Joseph Borg (joeborg) wrote :

We had the same issue in MicroK8s. Chris kindly provided this workaround https://github.com/ubuntu/microk8s/commit/73d181f2bce1d9834c42a7ecc43e11e0062c61e8

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.