pyqt Snap 构建成功,无法运行

eri*_*i0o 6 python snap

我使用 python3 插件构建了一个快照。它应该打开一个 PyQt5 应用程序。snap 构建没有问题,但是安装 snap 后,在命令行中调用已安装的 python 脚本失败,并出现以下错误。

我的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
Run Code Online (Sandbox Code Playgroud)

我使用以下命令构建和安装

snapcraft stage
snapcraft snap
sudo snap install pyqthelloworld_0.1.0_amd64.snap
Run Code Online (Sandbox Code Playgroud)

在命令行中

$ 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)
Run Code Online (Sandbox Code Playgroud)

怎么了?以及如何调试快照中的类似错误?

我正在使用 Ubuntu 16.04 LTS 64 位

编辑:检查是否存在编码(这是正确的吗?)

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
Run Code Online (Sandbox Code Playgroud)

Edit2:我现在得到(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)
Run Code Online (Sandbox Code Playgroud)

澄清一下,没有变化,只是在同一台(和更新的)Ubuntu 16.04 计算机上安装了一个更新的 snapcraft。

编辑3:

现在我添加了一个snap 文件夹,我在其中保留了 snapcraft.yaml(现在与这个问题开头的那个有点不同!)和一个处理语言环境错误的小包装器 - 我不认为应该需要。

现在,当我为已安装的 snap 运行命令 (pyqthelloworld) 时,我得到:

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)
Run Code Online (Sandbox Code Playgroud)

dho*_*ach 4

目前有两个与快照相关的错误会阻止此操作,但这两个错误都正在修复中:

您可以检查一下您的快照内容并查看是否有任何encodings模块已发货?


ser*_*ens 2

我认为你很可能是 hashbang 问题的受害者,最新版本的 snapcraft 应该可以解决这个问题,如果没有其他选择就是使用相对路径,command那么本质上command就是command: usr/bin/pyqthelloworld