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)
share|improve this question

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?

share|improve this answer
    
I didn't knew how to proper check, so I added local find output on my answer. – Elric Jun 17 '16 at 22:33

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 essentially command is command: usr/bin/pyqthelloworld

share|improve this answer
    
Hey, I used a tiny wrapper to win the locale error, but am stuck again, Qt is throwing a new error now. – Elric Sep 19 '16 at 23:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.