Я пытаюсь заморозить свое приложение на Python в Linux (Ubuntu 16.04) с помощью pyinstaller. По неизвестным причинам pyinstaller не включает библиотеку GTK в двоичный файл. Я получаю следующую ошибку:
ERROR:webview:GTK cannot be loaded
Traceback (most recent call last):
File "webview/__init__.py", line 66, in import_gtk
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "/usr/local/lib/python3.4/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
File "webview/gtk.py", line 25, in <module>
File "gi/__init__.py", line 79, in require_version
ValueError: Namespace WebKit not available
ERROR:webview:QT cannot be loaded
Traceback (most recent call last):
File "webview/__init__.py", line 79, in import_qt
File "/usr/local/lib/python3.4/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
File "webview/qt.py", line 68, in <module>
ImportError: This module requires PyQt4 or PyQt5.
Traceback (most recent call last):
File "ui.py", line 37, in <module>
File "webview/__init__.py", line 219, in create_window
File "webview/__init__.py", line 152, in _initialize_imports
Exception: You must have either QT or GTK with Python extensions installed in order to use pywebview.
[23678] Failed to execute script ui
Exception in thread Thread-1:
Traceback (most recent call last):
File "webview/__init__.py", line 177, in wrapper
File "webview/__init__.py", line 280, in load_html
NameError: name 'gui' is not defined
Двоичный код отлично работает на компьютере, который имеет все зависимости, но не работает на чистом компьютере. Насколько я понимаю, он не связывает все необходимые библиотеки.
Dockerfile, который я использую:
FROM ubuntu:xenial
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y wget python3 python3-dev python3-pip python3-gi python3-gi-cairo gir1.2-webkit-3.0
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip3 install -r requirements.txt
RUN pip3 install pyinstaller
# This image assumes that source files will be mounted in /usr/src/app
CMD [ "pyinstaller", "control-server-ui.spec", "-n", "control-server-ui" ]
#CMD [ "pyinstaller", "src/ui.py", "-n", "control-server-ui" ]
requirements.txt:
pywebview
pytest
Контроль-сервер ui.spec:
# -*- mode: python -*-
from PyInstaller.utils.hooks import collect_dynamic_libs
block_cipher = None
a = Analysis(['src/ui.py'],
pathex=['/usr/src/app'],
binaries=collect_dynamic_libs('webview', '.'),
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='control-server-ui',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='control-server-ui')