Problems with PyQtWebEngine on Mac
Davide Liessi <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <CAOXn3bp12B8yNJgxUtvrtGFC6ERdEFkiksY-i8G6882YZkjavA@mail.gmail.com> |
tl;dr Problems with QtWebEngineProcess in Mac app bundle: I need help in fixing MacPorts' PyQt. --- I'm trying to package a PyQt5 application as a Mac application bundle using py2app and I'm having some troubles in correctly packaging QtWebEngine. I'm seeing differences in behaviour between installing PyQt and py2app with MacPorts or in a virtualenv with pip. Consider the attached example: "test" is the main application, "app.py" is the py2app script, "build-app.sh" automates some manual steps (see later). --- Installing PyQt5, PyQtWebEngine and py2app with pip in a virtualenv and running python app.py py2app results in a perfectly working app bundle. --- Using MacPorts' Qt, PyQt5, PyQtWebEngine and py2app, I run python3.7 app.py py2app and the resulting app bundle crashes with qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Abort trap: 6 I then manually copy "libqcocoa.dylib" in the app bundle and run Qt's macdeployqt (see "build-app.sh", lines 10-14): the resulting app bundle crashes with Could not find QtWebEngineProcess Abort trap: 6 Finally, I add some missing symlinks in the app bundle (see "build-app.sh", lines 16-18): now the app bundle runs, but doesn't show the web page, with the following messages in the terminal dyld: Library not loaded: @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui Referenced from: /[...]/dist/test.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess Reason: image not found Feb 25 11:26:50 test[12069] <Error>: write failed: Broken pipe Feb 25 11:26:50 test[12069] <Error>: SeatbeltExecClient: write buffer length failed. Feb 25 11:26:50 test[12069] <Error>: SeatbeltExecClient: Writing the serialized profile failed. dyld: Library not loaded: @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui Referenced from: /[...]/dist/test.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess Reason: image not found From here I don't know how to proceed. I checked otool -L /[...]/dist/test.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess which outputs /[...]/dist/test.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess: @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.14.0, current version 5.14.1) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1561.40.112) /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 1.0.0) @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.14.0, current version 5.14.1) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0) @executable_path/../Frameworks/QtWebEngineCore.framework/Versions/5/QtWebEngineCore (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtQmlModels.framework/Versions/5/QtQmlModels (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtWebChannel.framework/Versions/5/QtWebChannel (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.14.0, current version 5.14.1) @executable_path/../Frameworks/QtPositioning.framework/Versions/5/QtPositioning (compatibility version 5.14.0, current version 5.14.1) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4) I tried to use install_name_tool to change the links to Qt components, but none of my trials worked. --- Unfortunately using PyPI's PyQt* for packaging the real application is not an option, because I need a full Qt installation to build some other components. Maybe it's just a matter of fixing some compilation flags in MacPorts' PyQt, but I don't know how to find out. I can provide more details on my system and on MacPorts' PyQt, if needed. Best wishes. Davide _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt
build-app.sh
(text/x-sh, 648 B)
#!/usr/bin/env bash
PYTHON="/opt/local/bin/python3.7"
QTROOT='/opt/local/libexec/qt5'
${PYTHON} app.py
APPBUNDLE=dist/test.app
rm ${APPBUNDLE}/Contents/Resources/qt.conf
mkdir -p ${APPBUNDLE}/Contents/PlugIns/platforms
cp ${QTROOT}/plugins/platforms/libqcocoa.dylib ${APPBUNDLE}/Contents/PlugIns/platforms/
${QTROOT}/bin/macdeployqt ${APPBUNDLE}
ln -s Versions/5/Helpers ${APPBUNDLE}/Contents/Frameworks/QtWebEngineCore.framework/Helpers
ln -s Versions/5/QtWebEngineCore ${APPBUNDLE}/Contents/Frameworks/QtWebEngineCore.framework/QtWebEngineCore
ln -s Versions/5/Resources ${APPBUNDLE}/Contents/Frameworks/QtWebEngineCore.framework/Resources
test
(application/octet-stream, 304 B) - not displayed
app.py
(text/x-python-script, 111 B)
from setuptools import setup
setup(
app = ['test'],
name = 'test',
setup_requires = ['py2app'],
)