When tried to run the python snap created, it gives below error
SyntaxError: Non-ASCII character ‘\xe2’ in file ultra2_master_armhf.snap on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
I have added following comments in python program as per the details mentioned in error, but still getting the error.
#!/usr/bin/python
-- coding: --
or:
#!/usr/bin/python
vim: set fileencoding= :
I have tried to run “sudo python .snap” command after installing snap.
Please suggest
It looks like you’re trying to execute the ultra2_master_armhf.snap file directly. This won’t work because it isn’t an executable file. The .snap file is a squashfs filesystem which gets mounted by snapd when you run snap install ultra2_master_armhf.snap --dangerous. Once installed you execute the command you have exposed via your snapcraft.yaml through, as an example, either /snap/bin/ultra2 or snap run ultra2.
I have executed the command “sudo snap install *.snap --devmode --dangerous” before running snap.
When tried to run the snap using “sudo python HCSR04Test.py”, it gives below error
python: can’t open file ‘HCSR04Test.py’: [Errno 2] No such file or directory
Find below is my snapcraft.yaml file
name: ultra2
version: master
summary: ultra2
description: |
This snap reads distance from the obstacle.
first of all please put pasted code between triple backticks so it gets formatted correctly (else we cant say if the indendation of your yaml is correct) …
you would have to put sudo inside your snap for this to work, better drop the sudo call there and have the user use sudo when calling your command.
Yes, snap list shows the snaps
ultra2 master x4 - - devmode
The snap version is as below
snap 2.32.9
snapd 2.33
series 16
kernel 4.4.0-1091-raspi2
The python program “sudo python HCSR04Test.py” is running fine and gives the distance information
Distance: 1.73cm
Distance: 6.12cm
Distance: 2.40cm
Distance: 6.15cm
Distance: 6.21cm
When it is bundled with snap, then getting some issue.