Build a snap with any version of Python I want


Is it possible to specify any version of Python that I want, when building with the core18 option in snapcraft.yaml?

It seems that I am forced to use Python 3.6 which is the default for Ubuntu 18.04, so am assuming that the “18” in “core18” is related to Ubuntu 18? What if I want Python 3.5 or Python 3.7 ? Are there specific entries I can add to snapcraft.yaml to make this happen? Or are we stuck with Python 3.6? Till when?

I searched the forums and there are some people talking about a Python 3.7 snap - which hasn’t eventuated. What’s the difference between stage-packages, snaps, and plugins anyway?

And there is another thread taking about using Python 3.6 when the default is Python 3.5, though it has no clear answer, and talks about building via which presumably is an online service which adds further constraints. I’m just trying to build on my Ubuntu 18.04 machine.


Yes, Ubuntu 18.04 to be exact.

You can always build one from source by adding a new part definition, there are also other ways to incorporate a Python distribution in your snap(PPA, stage-snaps) but this option is always available.


snapcraft help python tells you what you need to do to use a different python for a part.
Briefly, if you build python in a part and put that in part-name in the after clause for the python using plugin you have, the plugin will prefer that python installation.

Here’s a bit of a complex snap doing something like that, the part defined here, named git-ubuntu, has python3 in after and python3 is defined on line