Upgrading classic snap to core24 using snapcraft 8.3 causes python 3.12 errors at runtime

Another update – I think we’ve found what’s going on here, and there’s a couple things.

  1. With the aforementioned python3.11/12 changes, some internal paths will be wrong, and since it uses those to check for the os.py install location, it will spit out those warnings. But they seem to be ignorable, as the actual paths needed are correct. It can be silenced by additionally setting PYTHONHOME to $SNAP.
  2. The circular import error is caused by charset_normalizer looking for the private module lib-dynload, which for some reason lives in usr/lib/python3.12/lib-dynload instead of lib/python3.12/lib-dynload. It was lying about being a circular import error, it’s actually just a module not found error. As such, adding $SNAP/usr/lib/python3.12/lib-dynload to PYTHONPATH should fix that error. (I haven’t investigated why, but just adding $SNAP/usr/lib/python3.12 won’t work.) Further info and some other workarounds in case anyone wants to actually fix this: https://stackoverflow.com/questions/74182807/no-module-named-charset-normalizer-md-mypyc
  3. For a bonus side note that I have not investigated deeply, for some reason if python3-venv is not specified in stage-packages (even if it is specified in build-packages), it will not be available at build time. That seems illogical.

Some other helpful links that came up in the investigation process that I’m saving for posterity:

2 Likes