Unable to run python snap on Ubuntu core

Hi all,

I’m trying to create a python snap for ubuntu core but unable to run it on ubuntu core with the following error:

here is my project link:

my yaml is:

name: test-python-snap
base: core18
version: '0.1dev'
summary: Python Test Snap
description: |
    This is test snap for python applications.
grade: devel
confinement: strict
  - build-on: amd64 
    run-on: armhf

    source: .
    plugin: python
    python-version: python3
    requirements: ['requirements.txt']
    command: test-python-snap
    plugs: [home, network, network-bind, mount-observe]

python code is:

import click
import paho.mqtt.client as mqtt

@click.option('--name', prompt='enter your name', help='enter user name')
@click.option('--age', prompt='enter your age', help='enter user age')
def init(name, age):

    client = mqtt.Client()


Architecture details are:
any help please to make it work?
many thanks

Are you building the snap on an armhf device (your Ubuntu Core device)? Even with build-on: [armhf] you still need to actually use an armhf device to do the actual building. You cannot build an armhf snap on an amd64 machine easily.

A simple way to get a correct architecture snap is to use snapcraft remote-build --build-on=armhf, which will use the launchpad build servers.

Using remote-build does mean the development loop is a bit longer, though, because you need to wait for the workers to do their thing. You also have no way of interrupting a build or inspecting a broken build environment with --debug for example.

I’m building the snap on Ubuntu 19.10.

on an arm machine ?

I’m not sure, but the result of uname -a is:

Linux oli-systems 5.3.0-29-generic #31-Ubuntu SMP Fri Jan 17 17:27:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

this is intel, not arm … the binaries you produce can only run on intel/AMD …

use the snapcraft command that @lucyllewy gave you above…

I’m running that command and update you guys soon.
many thanks

1 Like

is that possible to install snapcraft on ubuntu core?

I tried to install but got error: error: snap "snapcraft" requires classic confinement which is only available on classic systems.

I tried to install it again after installing classic sudo snap install --channel=edge classic --devmode but still getting the same error.

The remote-build is taking too long to build.

on core:

snap install lxd
sudo lxd init # answer all questions by simply hitting enter
sudo lxc launch ubuntu:18.04 bionic # create an 18.04 container, call it bionic
sudo lxc exec bionic -- bash # enter the container and start a shell (you can leave it with ctrl-d or the "exit" command)

inside the container you can just snap install snapcraft, git clone your tree and use snapcraft with the --destructive-mode option …

but i doubt running it on something like a raspberry pi with SD card will be faster than launchpad …

1 Like

I wonder if I create a ubuntu 18.04 container, it will again give rise to the architecture issue as daniel mentioned here:

well, you need to run all this on armhf hardware, to confirm you are running on armhf (i.e. not some intel machine) try:

dpkg --print-architecture

… inside the container … that shows you the packaging architecture in use …

1 Like

thanks again, orga.
lxd is installed using snap install lxd command.
but the sudo lxd init gives error:

sudo: lxd: command not found

note: there is (classic) before username, because previously I tried to install classic snap.

this is wrong, you can not install lxd inside the classic environment, leave it to be on the normal console again … (or reboot and simply dont use the (unmaintained) classic mode)

@ogra @lucyllewy
Thank you awesome team snapcraft.