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

    command: pyqthelloworld

    plugin: python3
    source: git://github.com/ericoporto/pyqthelloworld
    source-type: git
      - 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

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.


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)
  • 3
    – user180409
    Jun 8, 2016 at 19:08
  • I believe, it already passed thought as I have make a look on git repository. Could set correct answer or write new answer, if you remember the case, if is quiet old, 4 years ago.
    – user.dz
    Apr 22, 2020 at 12:44

2 Answers 2


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 didn't knew how to proper check, so I added local find output on my answer.
    – eri0o
    Jun 17, 2016 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

  • Hey, I used a tiny wrapper to win the locale error, but am stuck again, Qt is throwing a new error now.
    – eri0o
    Sep 19, 2016 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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