[PyQt] Problems with PyQtWebEngine on Mac

Davide Liessi davide.liessi at gmail.com
Tue Feb 25 10:48:27 GMT 2020


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build-app.sh
Type: text/x-sh
Size: 648 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200225/d8f69e62/attachment.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test
Type: application/octet-stream
Size: 304 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200225/d8f69e62/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: app.py
Type: text/x-python-script
Size: 111 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200225/d8f69e62/attachment.bin>


More information about the PyQt mailing list