snapcraft building arm snaps on raspberry PI

Snapcraft building arm snaps on raspberry pi! This post will focus on wrapping a python script using snap. Its recommended that you do this on ubuntu core 18, available from the ubuntu cd image repo here

Install snapd, snapcraft and lxd

sudo apt update && sudo apt upgrade
sudo apt install snapd
sudo snap install core
sudo snap install snapcraft --classic
sudo snap install lxd
sudo usermod -a -G lxd ${USER}
lxd init (answer the questions with their defaults)
reboot (this is important)

multipass doesnt work, so you need to install lxd

Getting your Python Project Ready

to use python inside a snap, you need a working setuptools env.

To install the latest version of setuptools, use:

sudo apt install python3-pip
pip3 install --upgrade setuptools
If you don’t already have a file, create one:


Inside the file, add some template code:

import os
from setuptools import setup
def read(fname):
   return open(os.path.join(os.path.dirname(__file__), fname)).read()

   name = "an_example_project",
   version = "0.0.1",
   author = "Your Name",
   author_email = "whoever@someplace",
   description = ("Description goes here"),
   license = "BSD",
   keywords = "example documentation tutorial",
   url = "",
       "Development Status :: 3 - Alpha",
       "Topic :: Utilities",
       "License :: OSI Approved :: BSD License",

The directory structure for your project may need changed: it should look like this:

|-- an_example_project
|   |--
|   |--
|   |--

building snaps on raspberry Pi – getting SNAP build files ready

Next, make a few files:

touch pyproject.toml:

Inside that file, add the following:

requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
name = "an_example_project"
version = 0.0.1
packages = "an_example_project"
install_requires =

You can then test if it all works with the following command:

python3 bdist_wheel

Once that works without error, then try to build your snap:

snapcraft --use-lxd

It takes a while to build on raspberry pi, but once its built, you can install with:

snap install ./an_example_project_armhf.snap --dangerous --devmode

To run as regular user privs:

snap run an_example_project

Or with a shell to explore the snap

snap run --shell an_example_project

To run as root privs:

sudo snap run an_example_project
sudo snap run --shell an_example_project

Ubuntu snap format is a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and the systemd init system³. The packages, called snaps, and the tool for using them, snapd, work across a range of Linux distributions and allow upstream software developers to distribute their applications directly to users³. Snaps are much easier to secure and much easier to produce than traditional deb packages¹. They offer operational benefits for organizations managing many Ubuntu devices, which will bring more robust updates and more secure applications across all form factors from phone to cloud¹. Snaps can be installed alongside traditional deb packages². These two packaging formats live quite comfortably next to one another and enable Ubuntu to maintain its existing processes for development and updates². The snap directory can contain the command-chain declaration, a list of commands that are run before the actual application(s) bundled inside the snap. This can help set up the environment that snaps need, without having to resort to convoluted use of wrapper scripts⁴.


Wikipedia. Accessed 14/04/2023.
(2) Ubuntu 16.04 LTS introduces “snaps” for new robust, secure app format. Accessed 14/04/2023.
(3) Canonical unveils 6th LTS release of Ubuntu with 16.04. Accessed 14/04/2023.
(4) What’s in a snap? | Ubuntu. Accessed 14/04/2023.
(5) The snap format | Snapcraft documentation. Accessed 14/04/2023.

Leave a Reply