ModuleNotFoundError: No module named 'pkg_resources'

A follow-up to Snap is unusable due to bad permissions - #22 by mr_cal.

Here’s my snapcraft.yaml, and I’m seriously out of options here :man_shrugging:

I’ve downgraded to core20 and gnome-3-38 because gnome extension causes a segfault.

The build gives me an error:

...
+ snapcraftctl build
+ make -j4 WITH_PYTHON=3.8 PLATFORM_PLUG=gnome-3-38-2004
+ make -j4 install WITH_PYTHON=3.8 PLATFORM_PLUG=gnome-3-38-2004 DESTDIR=/build/indicator-sound-switcher/parts/gnome-3-38-extension/install
install -d /build/indicator-sound-switcher/parts/gnome-3-38-extension/install/gnome-platform
install -D -m755 hooks-configure-desktop "/build/indicator-sound-switcher/parts/gnome-3-38-extension/install/snap/command-chain"/hooks-configure-desktop
install -d /build/indicator-sound-switcher/parts/gnome-3-38-extension/install/data-dir
install -d /build/indicator-sound-switcher/parts/gnome-3-38-extension/install/data-dir/icons
install -d /build/indicator-sound-switcher/parts/gnome-3-38-extension/install/data-dir/sounds
install -d /build/indicator-sound-switcher/parts/gnome-3-38-extension/install/data-dir/themes
install -D -m755 desktop-launch "/build/indicator-sound-switcher/parts/gnome-3-38-extension/install/snap/command-chain"/desktop-launch
Building indicator-sound-switcher 
+ snapcraftctl build
+ python3 -m venv /build/indicator-sound-switcher/parts/indicator-sound-switcher/install
+ SNAPCRAFT_PYTHON_VENV_INTERP_PATH=/build/indicator-sound-switcher/parts/indicator-sound-switcher/install/bin/python3
+ pip install -U pip setuptools wheel
Traceback (most recent call last):
  File "/snap/gnome-3-38-2004-sdk/current/usr/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
Failed to build 'indicator-sound-switcher'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
Build failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 324, in run
    self.build()
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 308, in build
    self.run_build_command(["snapcraft"], cwd=output_path, env=env)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/operation.py", line 62, in run_build_command
    return self.backend.run(args, cwd=cwd, env=full_env, **kwargs)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/lxd.py", line 718, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-focal-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/lpbuildd-git-proxy', '--env', 'SNAPPY_STORE_NO_CDN=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-91519826", "build-request-timestamp": "2024-08-20T15:07:00Z", "build_url": "https://launchpad.net/~build.snapcraft.io/+snap/67bd36622272fac52a0656a3584b10f1/+build/2573956"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--env', 'SNAPCRAFT_BUILD_FOR=amd64', '--', '/bin/sh', '-c', 'cd /build/indicator-sound-switcher && linux64 snapcraft']' returned non-zero exit status 2.
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=focal --arch=amd64 SNAPBUILD-2573956
Scanning for processes to kill in build SNAPBUILD-2573956

As far as I know, pkg_resources is a part of setuptools. My YAML file explicitly mentions python3-setuptools, but it’s somehow not found.

Please advice.

The build works perfectly on my host using the 15c7ed8 revision:


    ...stripped...

Priming indicator-sound-switcher 
+ snapcraftctl prime
Priming resources 
+ snapcraftctl prime
The command 'desktop-launch' for 'desktop-launch $SNAP/bin/launch.sh $SNAP/bin/indicator-sound-switcher' was resolved to 'snap/command-chain/desktop-launch'.
The command 'desktop-launch $SNAP/bin/launch.sh $SNAP/bin/indicator-sound-switcher' has been changed to 'snap/command-chain/desktop-launch $SNAP/bin/launch.sh $SNAP/bin/indicator-sound-switcher'.
Snapping |                                                                                                                                                                                             
Snapped indicator-sound-switcher_2.3.10_amd64.snap

Please try to do a clean build to see if the problem is reproducible in a clean environment. I would suggest using Multipass if you require a VM build.

Yes, that’s the version downgraded to core18, it does work. The core20 variant (139e9b1a) produces the above error about missing pkg_resources.

1 Like

I can reproduce the problem now:

snapcraft-indicator-sound-switcher # /snap/gnome-3-38-2004-sdk/current/usr/bin/pip3
Traceback (most recent call last):
  File "/snap/gnome-3-38-2004-sdk/current/usr/bin/pip3", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

Smells like a bug in the gnome-3-38-2004-sdk build snap.

Have you tried adding python3-pkg-resources as a stage-package?

I know this is a core22 example, but some python tools need a lot of packages: snapcraft/snap/snapcraft.yaml at 3a1b8a9491bd7927a73556215b4aa754b1c8745f · canonical/snapcraft · GitHub

1 Like