Building a Python Snap Package


I am trying to build snap a package for a python program.

My folder structure looks like this:

  • project-name
    • project-name
    • snapcraft.yaml

Currently I have the following in snapcraft.yaml:

name: project-name
version: 0.1
summary: ...
description: ...

grade: devel
confinement: devmode

    source: .
    plugin: python
    python-version: python3


Now I get the following error:
Failed to generate snap metadata: The specified command '' defined in the app 'project-name' does not exist or is not executable

I tried to follow the official python tutorial, but they always use remote git repositories and that’s not the case for me.

Python apps

Is in prime? The python plugin leverages, so it must install it Alternatively you could use what is explained on Scriptlets to run cp.


Thank you for your answer! I tried to follow the first tip.

I added the following

from setuptools import setup


Then I added bin/project-name

#!/usr/bin/env python

 import project_name

And I added this to snapcraft.yaml

    command: bin/project-name

But now I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: '.../project-name/bin/project-name

I am sorry for my very basic question!


You might be better off making sure you can, inside a venv and from within the source tree to a pip install .. Following that, make sure your application runs when executed outside that source directory to not accidentally load packages and modules from that tree to ensure everything was installed correctly.

Following that, your snapcraft project should work correctly mostly as is (unless you change command names or package names that is).


I had to delete the folders snapcraft created (parts, prime, snap and stage) and now it finds my file in the bin directory.

Now I have another problem

My program is written in Python 3.6 and uses for example f-strings. Now I get a SyntaxError.
But I can’t tell snapcraft to use python3.6 (python-version: python3.6 results to Failed to load plugin: properties failed to load for project-name: The 'python-version' property does not match the required schema: 'python3.6' is not one of ['python2', 'python3'].
Is it possible to use Python3.6?


I have the same problem. Were you able to find a solution?


For f-strings, you can pip install future-fstrings and use # -*- coding: future_fstrings -*- at the top of the file.

My code depends on other 3.6 features, though, and just installing Python3.6 in the snap doesn’t help, it will default to 3.5.


I got Python 3.6 working based on this comment: Build a snap with any version of Python I want

The sample given there is too complex, though. Here is an easy working example to follow: