Possible bug: broken python apps (incl. OpenDroneMap, and Fakecam) on core20

I assist with maintaining the OpenDroneMap snap here:

https://snapcraft.io/opendronemap

I’ve filed a bug report on the core20 tracker, and was recommended to report here:

https://github.com/snapcore/core20/issues/128

Our users have been reporting (infrequently, but consistently) an issue with our snap:

snap run opendronemap
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f2e195c7740 (most recent call first):
<no Python frame>

I was able to reproduce it under WSL2 as well as 20.04LTS in Hyper-V.

In speaking with Dani, they indicated that they have seen similar breakage even with their own snaps and they recommended that we downgrade our core to core18 and then adjust the stage-packages to reflect this.

Our snapcraft yaml(s):

https://github.com/OpenDroneMap/ODM/blob/master/snap/snapcraft.yaml

User threads (other reports/reproductions):

https://community.opendronemap.org/t/snap-opendronemap-python-fail-on-ubuntu-21/9949?u=saijin_naib
https://community.opendronemap.org/t/odm-and-ubuntu-20-04/8223?u=saijin_naib
https://community.opendronemap.org/t/issue-with-opensfm-reconstruction/7381/11?u=saijin_naib

Does anyone have any further guidance on this, or ways that I can collect more information if this is a confirmed bug?

Thanks!

I’ve found this with any Python app in a Core20-based Snap using the gnome-3-38 extension - it is impacting my ability to migrate fakecam to core20. I haven’t tried to narrow down whether this is ALL Core20-based python apps or whether the use of the gnome extension is important - I believe ODM doesn’t use the extension, but I might be misremembering.

It seems that Snapcraft isn’t installing any python dependencies resulting in the encodings module to be missing, among a whole slew of others:

  • python3: Pre-Depends: python3-minimal
  • python3-minimal: Pre-Depends: python3.8-minimal
  • python3.8-minimal:
    Pre-Depends: libc6 (>= 2.29)
    Depends: libpython3.8-minimal (= 3.8.10-0ubuntu1~20.04.2), libexpat1 (>= 2.1~beta3), zlib1g (>= 1:1.2.0)
    
  • libpython3.8-minimal: this is the missing package providing the encodings module.

Explicitly including python3 as a stage-packages entry does not install the dependencies, so I would suggest the dependency parser/resolver is broken.

cc: @sergiusens

@Saijin_Naib, I’ve amended the topic title to include Fakecam in the list of broken snaps to illustrate that it’s affecting multiple Snaps.

1 Like

As a workaround, I tried adding the following to stage-packages to install all the missing python3 packages that are skipped when attempting to stage python3:

    stage-packages:
      - libpython3.8-minimal
      - libpython3.8-stdlib
      - python3
      - python3-minimal
      - python3.8-minimal

However, this caused fakecam to not be installed into the Snap by the python plugin at all. There are no fakecam files in my snap when adding these stage-packages, so this is not a fix.

1 Like