Why isn't there a python snap with the latest version?

Hi! everyone

I really like snaps, I used a lot in Ubuntu 22.04, but I always have this thought, if Ubuntu mostly pack older python version for the system install, Why isn’t there a python snap with the latest version? so we can keep isolated the system, I know you can install latest version of python using a PPA but that’s no the point, I wonder if there is no use on a python snap or there may be to hard to make?

I look at a wonderful snap OpenJDK Snap that give us the latest openjdk isolated and also can be use for development or other uses.

I think a python snap similar to that OpenJDK maybe really useful for data science that really just need to run scripts

What do you think of this?


I asked myself this same question earlier this week.

There are Python snaps on the store, but most of them seem to be purpose built towards the needs of the developer. I think the best example for a Python snap is the python0 snap on the store: https://snapcraft.io/python0.

This snap seems to be built for research purposes, but I think it is a good example of what would need to be done to incorporate Python into its own standalone snap. I would be interested in trying to snap Python 3.10 to see what potential blockers are.

There’s quite a lot of reasons why it isn’t made:

  • The Python snap, when in strict confinement, can’t access to resources that isn’t allowed by confinement, make it less useful in some situations like accessing local libraries, etc .

  • The in-snap directories is read-only thus you can’t write files into them, some operations like PyPI package installation will not work

    In order the workaround this build-time/run-time patching is required to redirect them to snap-writable directories like SNAP_USER_DATA etc.

  • Some PyPI package installation may need to build native libraries where the toolchain may not be available in the snap

  • No one devotes the resources to make all the changes to work-around the limitations including but not limited to the above ones, yet

1 Like

So the answer is: isolating python and make it work is to hard and need a lot of planning and workarounds.

Thanks for clarifying this, it’s true Python and pip use a lot of other tools chains, that’s why there is a python category in the Ubuntu Packages.

It would be nice to have a up to date Python snap, maybe in the future :slight_smile:

1 Like

Probably because it doesn’t make much sense. There is pyenv or better yet venv to switch between versions, which is much more convenient for development.

It may, however, avoid most of the limitations caused by the confinement, by making the Python snap run in classic confinement, however, it also introduces some problems due to differences between the host system and the base snaps(Ubuntu Core 16/18/20/22…):

  • The external commands(toolchains) Python calls that are outside of the snap must be taken care of to avoid accidentally loading the incompatible libraries inside the snap
  • Python in snap considers itself run in a different operating system(which is the system of the base snap), some heristics base on this fact may not work

I’d say building the snap may still be useful in some usecases, though, with all of the limitations in mind.