I built a snap using python3 plugin. It should open a PyQt5 app. The snap built with no problem, but after the snap is installed, calling the installed python script in command line fails with the error below.
My snapcraft.yaml
name: pyqthelloworld
version: 0.1.0
summary: pyqt hello world
description: |
a pyqt5 python3 hello world test
confinement: strict
apps:
pyqthelloworld:
command: pyqthelloworld
parts:
pyqthelloworld:
plugin: python3
source: git://github.com/ericoporto/pyqthelloworld
source-type: git
stage-packages:
- python3-pyqt5
- libc-bin
- locales
I built and installed using the commands below
snapcraft stage
snapcraft snap
sudo snap install pyqthelloworld_0.1.0_amd64.snap
In command line
$ pyqthelloworld
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007fb8fc0ff700 (most recent call first):
Aborted (core dumped)
What's wrong? And how do I debug similar errors in snaps?
I am using Ubuntu 16.04 LTS 64-bit
Edit: checking if encodings is there (is this correct?)
user@pc:~/git/pyqthelloworld/snap$ find . -iname encodings
./prime/usr/lib/python3.5/encodings
./parts/pyqthelloworld/install/usr/lib/python3.5/encodings
./stage/usr/lib/python3.5/encodings
Edit2: I am now getting (snapcraft 2.15.1):
$ pyqthelloworld
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Reinstalling the application may fix this problem.
Aborted (core dumped)
Just to clarify, no changes, just a newer snapcraft on the same (and updated) Ubuntu 16.04 computer.
Edit3:
Now I added a snap folder, where I am keeping the snapcraft.yaml (which is now a little different than the one in the beginning of this question!) and a little wrapper to deal with the locale error - which I don't think should be needed.
Now when I run the command (pyqthelloworld) for the installed snap I am getting:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.
Reinstalling the application may fix this problem.
Aborted (core dumped)
There are currently two bugs related to snaps which block this, both are in the works to be fixed though:
Can you check the contents of your snap and see if there are any
encodings
modules shipped?I think you were most likely a victim of the hashbang problem, recent versions of snapcraft should solve this, if not one other option is to use a relative path in
command
so that essentiallycommand
iscommand: usr/bin/pyqthelloworld