I should get a copy of python included in my snap as far as I understand.
However, it does not inlcude the interpret, but a symlink that resolves to the base snap. Hence, modules are not loaded from the dist-packages in the snap.
This is how the snap looks if I shell into the snap using snap run --shell test-thing :
root@ubuntu:~# which python3
/snap/test-thing/x2/bin/python3
root@ubuntu:~# ls -al /snap/test-thing/x2/bin/python3
lrwxrwxrwx 1 root root 16 Oct 13 20:20 /snap/test-thing/x2/bin/python3 -> /usr/bin/python3
If I change the snapcraft definition to install package using pip with an override-build, the symlink is the same, but the module in dis-packages in the snap seem to be found !
So, while I have a working method, I wouls still like to know the different. Why do pip package work [ the are importable modules ] , but python debs don’t work [ they are not importable modules ].
Typically snapcraft won’t include packages that are found in the base snap unless explicitly requested. You need more packages to include everything in your snap.
Here is an example of a fully staged python:
Here is an example of supporting python stage-packages using PYTHONPATH:
The documentation for the python plugin seems to suggest it should be included automatically, if you specify a python3- prefixed package in stage-packages - that’s my main source of confusion
Perhaps it’s a bug in that case.
Thanks for the tip on PYTHONPATH@cjp256 - that looks like the I’m missing when the interpreter from base is used, I should of just tried that !