Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQt5, PyQtWebEngine, bdist_mac: Cannot find QtWebEngineProcess #933

Closed
mikedarcy opened this issue Feb 25, 2021 · 31 comments · Fixed by #2127
Closed

PyQt5, PyQtWebEngine, bdist_mac: Cannot find QtWebEngineProcess #933

mikedarcy opened this issue Feb 25, 2021 · 31 comments · Fixed by #2127

Comments

@mikedarcy
Copy link

mikedarcy commented Feb 25, 2021

We have PyQt5 app that uses the PyQtWebEngine (embedded Chromium browser) component, which we freeze with cx_Freeze from a venv virtual environment. We successfully frozen this application in the past (on both Windows and Mac) using cx_Freeze 6.3, Python 3.7, and PyQt 5.11.3.

Lately, I have been trying to update our out-of-date application dependencies to use cx_Freeze 6.5, Python 3.8 and PyQt 5.15.2 but I am getting an app crash when trying to load the part of our application that uses PyQtWebEngine. The error is that the frozen application cannot find a required runtime component, QtWebEngineProcess, which is essentially the wrapper of the bundled Chromium engine. See here for more information about QtWebEngineProcess.

I believe the problem is somewhere in setRelativeReferencePaths during bdist_mac processing. The program in the exe.macosx-10-* build directory does work correctly, but the one in resulting bundled mac app directory does not.

I've tried this with both Python 3.7 and 3.8 on MacOSX Catalina 10.15.7 and with various versions of PyQt 5.14 and 5.15. Note that after PyQt 5.11.3, the PyQtWebEngine components are bundled separately and have to be installed from PyPi via pip install PyQtWebEngine. I have also tried this with every released version of cx_freeze from 6.4 onward, including 6.6.dev0.

There is some history of this specific file (QtWebEngineProcess) being a thorn in the side of various Python freezing environments (e.g. pyinstaller), so I am not that surprised at this regression popping up for us after trying to jump up so many versions of PyQt at once. I guess I'm hoping someone who knows more about the subtleties of the Mac linking mechanisms like @cainesi can work some magic here.

I created a barebones PyQt5 app and corresponding cx_freeze setup.py script that can be used to reproduce this. You can reference it in this gist: https://gist.github.com/mikedarcy/44f385488715dc808dbb9fc8b3f3c60d. Just create a new 3.7/3.8 virtual env and pip install cx_freeze pyqtwebengine followed by python setup.py bdist_mac then try to run the bundled app. If the window draws and renders some text in the window body, then its working, otherwise it will just crash immediately.

Thanks for your time.

@cainesi
Copy link
Contributor

cainesi commented Feb 25, 2021

Hi @mikedarcy. The dynamic links of the files in the exe-directory are not updated yet. So the copy of the program there could still find the original (un-frozen) libraries on your computer. I.e., it can often run even if some files are missing from the freeze.

Here is a script that you can use to run your target script and get a rough listing of the libraries it loads into memory. If you compare the output of that, with the contents of the exe directory, it might reveal what is missing. (If you want to upload the output of the script, and the listing from the directory, I can take at look as well.)

script_runner.py.zip

@mikedarcy
Copy link
Author

mikedarcy commented Feb 25, 2021

I've run this, but unfortunately it s not very illuminating. The component that does not load, QtWebEngineProcess is not a dynamic library or Python module - it is a separate, bundled executable. It does not appear in the output below, even though the app launched successfully when I ran it with script_runner.py.

Note that the this file is in the result frozen app bundle directory - it's just that it can't be found after the re-linking. The location of the file in the frozen app dir is: PyQt5 Webengine Test.app/Contents/MacOS/lib/PyQt5/Qt/lib/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app.

Here's the output of script-runner.py

(test-venv) buildbot@4595 src % python script_runner.py pyqt5-webengine-test.py
running script: /Users/buildbot/src/pyqt5-webengine-test.py
WARNGING: Underlying script exited with error.

Additional modules loaded by script: pyqt5-webengine-test.py
    [  1] PyQt5
    [  2] PyQt5.QtCore
    [  3] PyQt5.QtGui
    [  4] PyQt5.QtNetwork
    [  5] PyQt5.QtPrintSupport
    [  6] PyQt5.QtWebChannel
    [  7] PyQt5.QtWebEngineCore
    [  8] PyQt5.QtWebEngineWidgets
    [  9] PyQt5.QtWidgets
    [ 10] PyQt5.sip
    [ 11] _bootlocale
    [ 12] atexit
    [ 13] importlib
    [ 14] importlib._bootstrap
    [ 15] importlib._bootstrap_external
    [ 16] importlib.abc
    [ 17] importlib.machinery
    [ 18] importlib.util
    [ 19] pkgutil
    [ 20] sip
    [ 21] weakref

Additional libraries loaded by script: pyqt5-webengine-test.py
    [  1] /
    [  2] /Library/Application Support/CrashReporter/SubmitDiagInfo.domains
    [  3] /Library/Caches/com.apple.iconservices.store/8110DF64-8076-32C5-B0B3-F6DA06E696D3.isdata
    [  4] /Library/Caches/com.apple.iconservices.store/D186CB94-9BD0-3FC2-B8A2-A39CAD9C27F3.isdata
    [  5] /Library/Preferences/Logging/.plist-cache.VUirzTI4
    [  6] /System/Library/Caches/com.apple.IntlDataCache.le.kbdx
    [  7] /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/Assets.car
    [  8] /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/DarkAquaAppearance.car
    [  9] /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/SystemAppearance.car
    [ 10] /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/VibrantLightAppearance.car
    [ 11] /System/Library/Extensions/AppleIntelHD4000GraphicsVADriver.bundle/Contents/MacOS/AppleIntelHD4000GraphicsVADriver
    [ 12] /System/Library/Extensions/AppleIntelIVBVA.bundle/Contents/MacOS/AppleIntelIVBVA
    [ 13] /System/Library/Fonts/Apple Symbols.ttf
    [ 14] /System/Library/Fonts/Helvetica.ttc
    [ 15] /System/Library/Fonts/Menlo.ttc
    [ 16] /System/Library/Fonts/SFNS.ttf
    [ 17] /System/Library/Fonts/SFNSMono.ttf
    [ 18] /System/Library/Fonts/Supplemental/Apple Chancery.ttf
    [ 19] /System/Library/Fonts/Supplemental/NotoSansSyriac-Regular.ttf
    [ 20] /System/Library/Fonts/Supplemental/Times New Roman.ttf
    [ 21] /System/Library/Fonts/Supplemental/Zapfino.ttf
    [ 22] /System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/AppleKeyboardLayouts-L.dat
    [ 23] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore
    [ 24] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtDBus.framework/Versions/5/QtDBus
    [ 25] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtGui.framework/Versions/5/QtGui
    [ 26] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtNetwork.framework/Versions/5/QtNetwork
    [ 27] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtPositioning.framework/Versions/5/QtPositioning
    [ 28] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport
    [ 29] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtQml.framework/Versions/5/QtQml
    [ 30] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtQmlModels.framework/Versions/5/QtQmlModels
    [ 31] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtQuick.framework/Versions/5/QtQuick
    [ 32] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtQuickWidgets.framework/Versions/5/QtQuickWidgets
    [ 33] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebChannel.framework/Versions/5/QtWebChannel
    [ 34] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/icudtl.dat
    [ 35] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_devtools_resources.pak
    [ 36] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_locales/en-US.pak
    [ 37] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_resources.pak
    [ 38] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_resources_100p.pak
    [ 39] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_resources_200p.pak
    [ 40] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Versions/5/QtWebEngineCore
    [ 41] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets
    [ 42] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/lib/QtWidgets.framework/Versions/5/QtWidgets
    [ 43] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib
    [ 44] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtCore.abi3.so
    [ 45] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtGui.abi3.so
    [ 46] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtNetwork.abi3.so
    [ 47] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtPrintSupport.abi3.so
    [ 48] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtWebChannel.abi3.so
    [ 49] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtWebEngineCore.abi3.so
    [ 50] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtWebEngineWidgets.abi3.so
    [ 51] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/QtWidgets.abi3.so
    [ 52] /Users/buildbot/src/test-venv/lib/python3.7/site-packages/PyQt5/sip.cpython-37m-darwin.so
    [ 53] /dev/urandom
    [ 54] /private/etc
    [ 55] /private/etc/hosts
    [ 56] /private/var/db/analyticsd/events.whitelist
    [ 57] /private/var/db/mds/messages/502/se_SecurityMessages
    [ 58] /private/var/db/timezone/tz/2021a.1.0/icutz/icutz44l.dat
    [ 59] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/0/com.apple.LaunchServices.dv/com.apple.LaunchServices-1082-v2.csstore
    [ 60] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/C/com.apple.iconservices/store.index
    [ 61] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/C/org.python.python/com.apple.metal/3902/libraries.data
    [ 62] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/C/org.python.python/com.apple.metal/3902/libraries.maps
    [ 63] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/C/org.python.python/com.apple.metal/Intel HD Graphics 4000/functions.data
    [ 64] /private/var/folders/_6/3n_3cjtx7mv6nsr4285p1kq40000gp/C/org.python.python/com.apple.metal/Intel HD Graphics 4000/functions.maps
    [ 65] /usr/share/icu/icudt64l.dat

Here is the (lengthy) recursive directory listing of all of the files in the frozen result app - QtWebEngineProcess.app is definitely there:

EDIT: 3/1/21 - Took this out since it was huge and not really relevant to the issue anymore and just made scrolling down a pain. The bottom line is that QtWebEngineProcess.app is in the frozen app it just can't be found at runtime.

@mikedarcy
Copy link
Author

I was looking at how pyinstaller handles this and it looks like they set an environment variable, QTWEBENGINEPROCESS_PATH (documented here) on their Mac builds: see https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/rthooks/pyi_rth_pyqt5webengine.py.

Is there a way this could be automatically be done via hooks during builds including PyQt5 (+WebEngine) in cx_freeze? Alternatively, how could I configure cx_freeze to add this to my executable entry for specific apps during bdist_mac processing?

@marcelotduarte
Copy link
Owner

Is there a way this could be automatically be done via hooks

Yes, that is possible. I'll take a look.

I think that you can, as a workaround, set os.environ before the calls to pyqt with the base directory as os.path.dirname(sys.executable)) + "lib"

@cainesi
Copy link
Contributor

cainesi commented Feb 26, 2021

For what it's worth, I got the test script working by:

  1. Adding the following to the top of the program (before any of the PyQt5 imports):
import os, sys
if getattr(sys, "frozen", False) and getattr(sys, "executable", False):
    exedir = os.path.join(os.path.dirname(sys.executable))
    wepdir = os.path.join(exedir, 'lib', 'PyQt5', 'Qt', 'lib',
      'QtWebEngineCore.framework', 'Helpers', 'QtWebEngineProcess.app',
      'Contents', 'MacOS', 'QtWebEngineProcess')
    os.environ['QTWEBENGINEPROCESS_PATH'] = wepdir
  1. Copying the contents of PyQt5/Qt/lib/QtWebEngineCore.framework/Resources into the .app/Contents/MacOS directory.

I'm sure there is a better way to make it find the resource files, but I don't know enough about how PyQt5/Qt5 is finds files. @marcelotduarte, I suspect this problem (at least the resource files--might still need to set the environment variable) goes away once cx_freeze is fixed to dynamically link to the copies of libraries inside the modules.

@mikedarcy
Copy link
Author

Thanks for looking into this guys. 🥇

So, is the environment variable setting something that ultimately can be injected into the frozen executable and not something I'd have to remember to conditionally include (just for Mac) in my code when I have a module that imports the webengine stuff? I think that is what @marcelotduarte was suggesting but want to be sure. Also, don't get me wrong, I absolutely appreciate the workaround and if there is no other solution would likely use it in the near term.

Also, not to be a ninny, but the pyinstaller hook is doing this on MacOS to find the resource files by looping through the library "frameworks". I don't know if makes sense to do something similar or not, just wanted to provide some reference.

@cainesi
Copy link
Contributor

cainesi commented Feb 26, 2021

Fwiw, the code wouldn't need to be in every module that imports webengine. It should just need to be run once when the main frozen script starts.

But yes, I think it could probably be handled with a hook.

@mikedarcy
Copy link
Author

Sorry, I should have clarified that better. We have multiple executables in our frozen app "bundle" that individually use the webengine, so presumably it would have to be added to each logical executable -- not a big deal, its only a few.

Great if it could be handled globally with a hook!

@marcelotduarte
Copy link
Owner

marcelotduarte commented Mar 1, 2021

I absolutely appreciate the workaround and if there is no other solution would likely use it in the near term.

I mean a temporary workaround.

First, I tested the sample (of your gist) on Ubuntu, and:
pip install pyqt5
build, run, fail...
then, I see that I forget something: pip install PyQtWebEngine
build, run, fail, same error.
then, rm -rf build
and, build, run, and it's ok (I see the message).

Maybe a clean build can resolve some issues.

I do not have access to mac but have access to GitHub Action CI/CD (GA) with macOS 10.15 and did some tests.
I merged your gist temporarily in the develop branch (83ba634) with minimal change.
Build it as build_exe and run (In GA I can't see the screen, only errors if it arises), and the result is:

  • py37: Run ./cx_Freeze/cx_Freeze/samples/pyqt5-webengine/$(cat BUILD_DIR)/pyqt5-webengine-test &
    The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.
    Chromium on macOS will fall back to software rendering in this case.
    Hardware acceleration and features such as WebGL will not be available.
    Unable to create basic Accelerated OpenGL renderer.
    Unable to create basic Accelerated OpenGL renderer.
    Core Image is now using the software OpenGL renderer. This will be slow.

  • py38: Run ./cx_Freeze/cx_Freeze/samples/pyqt5-webengine/$(cat BUILD_DIR)/pyqt5-webengine-test &
    ./cx_Freeze/cx_Freeze/samples/pyqt5-webengine/$(cat BUILD_DIR)/pyqt5-webengine-test &
    shell: /bin/bash -e {0}
    env:
    pythonLocation: /Users/runner/hostedtoolcache/Python/3.8.8/x64
    The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.
    Chromium on macOS will fall back to software rendering in this case.
    Hardware acceleration and features such as WebGL will not be available.
    Unable to create basic Accelerated OpenGL renderer.
    Unable to create basic Accelerated OpenGL renderer.
    Core Image is now using the software OpenGL renderer. This will be slow.
    [2738:15619:0227/223155.831195:ERROR:command_buffer_proxy_impl.cc(141)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.

Apparently, there are no errors.

I did same test with bdist_mac.
To run I used: open ./PyQt5WebengineTest.app
No errors, no messages like in build_exe (but I cannot see the screen).

Can you try a clean build?

@mikedarcy
Copy link
Author

I have run clean builds many times trying to get this to work, and it never has had any effect. In fact, the automated build process that I use to freeze these applications always uses a fresh directory and new virtual environment every time a build is run. I've also tried this without a virtual environment (using pip --user install method), and get the same results.

I can also run the app successfully with just build_exe output directory. The problem occurs in bdist_mac app freezing and result app application directory. I tried your open ./PyQt5WebengineTest.app on my 10.15 system, in a terminal, and what happens is the app runs, crashes, and exits without the real exit code. I'm guessing this is due to how the system is spawning the child process with open, but don't know definitively.

However, in the same terminal I ran the frozen executable directly from within the app directory instead and indeed the exit code is there:

buildbot@4595 build % "./PyQt5 Webengine Test.app/Contents/MacOS/pyqt5-webengine-test" ; echo $?
Could not find QtWebEngineProcess
zsh: abort      "./PyQt5 Webengine Test.app/Contents/MacOS/pyqt5-webengine-test"
134

I'm not sure what you mean by "I can see the screen" when you tried with bdist_mac in the CI environment. You mean you could see the window and web page render? How? I must be misunderstanding something there.

Could you try to run the bdist_mac outputted app in the CI environment using the approach above and see if it reproduces the error?

Thanks again.

@marcelotduarte
Copy link
Owner

I'm not sure what you mean by "I can see the screen"

No, sorry, I mean "I cannot"

@marcelotduarte
Copy link
Owner

Could you try to run the bdist_mac outputted app in the CI environment using the approach above and see if it reproduces the error?

Yes, now I got the error 😅

The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.
Chromium on macOS will fall back to software rendering in this case.
Hardware acceleration and features such as WebGL will not be available.
Could not find QtWebEngineProcess
/Users/runner/work/_temp/328a80e8-3f53-47d7-825c-0813d55310f9.sh: line 1: 2722 Abort trap: 6 ./PyQt5WebengineTest.app/Contents/MacOS/pyqt5-webengine-test
Error: Process completed with exit code 134.

@cainesi
Copy link
Contributor

cainesi commented Mar 1, 2021

I did some testing over the weekend but was tied up and couldn't report back.

The problem seems to be that QtWebEngineCore (which is dynamically linked to by QtWebEngineWidgets.abi3.so) looks for the resources and QtWebEngineProcess executable at locations relative to itself.

The way the freeze process works, all of the dynamic libraries linked to by python modules get copied into the executable directory (Content/MacOS, in an app bundle).

However, the dynamic links are not updated by build_exe, only by bdist_mac. So the the copy of the application in the exe-* directory will still find the library at lib/PyQt5/Qt/lib/QtWebEngineCore.framework/Versions/5/QtWebEngineCore (and ignore the copy in the executable directory), and everything works. But when the .app bundle is created, the the dynamic linking references are updated, so the app finds the copy of QtWebEngineCore in the executable directory (Content/MacOS) and things break (at least without the workarounds suggested above).

@marcelotduarte, I think the plan is to change the freeze process so that when a dynamic library is found inside a module that is being included on the file system, then we use that copy of the dynamic library instead. Based on my testing, once we make that change this problem should be mostly fixed.

For future reference, the two other things we'll need to do are to:

  1. Change the dynamic link update code so that it uses @loader_path (relative to the dynamic library) for the dynamic links instead of @executable_path (relative to the executable). This is required so that the libraries will work with executables located outside the base executable directory (e.g., QtWebEngineProcess).
  2. Scan through the module contents to find any other Mach-O files that are not directly or indirectly linked to from the python modules. Or at least provide an option to specify other particular files to analyze. The issue is that there could be dynamic libraries linked to from embedded executables (again, e.g., QtWebEngineProcess) but not from any of the python modules. I suppose we could also handle that with a hook, on a case-by-case basis.

@cainesi
Copy link
Contributor

cainesi commented Mar 1, 2021

Sorry, I should have clarified that better. We have multiple executables in our frozen app "bundle" that individually use the webengine, so presumably it would have to be added to each logical executable -- not a big deal, its only a few.

If you want to make it a little less painful, you could make a 'cxfixup.py' file with the contents below, and then import it into each of your executables.

I think this is probably going to get fixed, but it might take a bit of time.

import sys, os
if sys.platform=="darwin":
    if getattr(sys, "frozen", False) and getattr(sys, "executable", False):
        executableDir = os.path.join(os.path.dirname(sys.executable))
        webEngineProcessLocation = os.path.join(executableDir, 'lib', 'PyQt5', 'Qt', 'lib',
           'QtWebEngineCore.framework', 'Helpers', 'QtWebEngineProcess.app',
           'Contents', 'MacOS', 'QtWebEngineProcess')
        os.environ['QTWEBENGINEPROCESS_PATH'] = webEngineProcessLocation

@Hellfireone
Copy link

Same Problem here only with a Windows 10 Machine ! pls help

@cainesi
Copy link
Contributor

cainesi commented Apr 13, 2021

Same Problem here only with a Windows 10 Machine ! pls help

Are you including pyqt in the zip file?

@Hellfireone
Copy link

Hi , i tryed many things
first of all , pip install PyQt5 , pip install PyQtWebEngine

from cx_Freeze import *

company_name = 'test'
product_name = 'test'
bdist_msi_options = {
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]%s%s' % (company_name, product_name),
}

includes = ['atexit','PyQt5']
zip_include_packages = ['*']

packages = ['PyQt5',]
executables=[Executable("test.py",
base="Win32GUI",
icon=r"C:\Users\User\PycharmProjects\test\icon.ico",
shortcut_name='test',
shortcut_dir="DesktopFolder")]
setup(name="test",
version="0.1",
author="test",
description="test",
executables=executables,
options={'bdist_msi': bdist_msi_options,'build_exe':{"packages":packages,"zip_exclude_packages": [],'includes':includes,'zip_include_packages':zip_include_packages,'include_files':['Faehigkeiten.png','icon.ico','x.png'],'include_msvcr':True}})

i try to build a installer with , python setup.py bdist_msi

but evertime exe and installer not working

@Hellfireone
Copy link

ok.ok i see my mistake , i write PyQt5 in zip_exclude_packages and now it works . Thx :)

@Hellfireone
Copy link

now .exe is working but installer isn`t , any help ?

@cainesi
Copy link
Contributor

cainesi commented Apr 13, 2021

now .exe is working but installer isn`t , any help ?

Can you give more details about how the installer is not working?

@Hellfireone
Copy link

yes so i use command python setup.py bdist_msi , after that a msi installer is created (sorry for my English) i use the installer , a shortcut is createt , i start my own Programm , my GUI is starting but my Script i wrote is not working (in my script/Python modul there is a Keyboard funktion if i Press 1 , the Programm muss press 6 ) but its not working ... in the .exe it is working

@decoybuilder
Copy link

decoybuilder commented Dec 18, 2021

Hello, I'm trying to use cx_freeze and pyfladesk which uses pyqt5 to make a standalone flask app. It works on windows but on mac. I have the same problem cannot find qtwebengineprocess. I've tried to add

import sys, os
if sys.platform=="darwin":
    if getattr(sys, "frozen", False) and getattr(sys, "executable", False):
        executableDir = os.path.join(os.path.dirname(sys.executable))
        webEngineProcessLocation = os.path.join(executableDir, 'lib', 'PyQt5', 'Qt', 'lib',
           'QtWebEngineCore.framework', 'Helpers', 'QtWebEngineProcess.app',
           'Contents', 'MacOS', 'QtWebEngineProcess')
        os.environ['QTWEBENGINEPROCESS_PATH'] = webEngineProcessLocation

to my app.py script, to my setup script and to the init script in pyfladesk that imports pyqt5 and copied the contents of the PyQt5/Qt/lib/QtWebEngineCore.framework/Resources to the MacOS folder after pressing show package contents.

Any help would be much appreciated.

@stuwilmur
Copy link

Hi @marcelotduarte, @cainesi, I just came across this exact issue when freezing my app: is there any superior way to overcome it than the workaround mentioned above, or is that still the best approach? Thanks in advance for your help.

@stuwilmur
Copy link

Actually, I overcame this in the end...by realising that what I was trying to achieve didn't require the QtWebEngine at all. All I wanted to do was render some fairly simple HTML, which can be done with the QTextEdit class. Posting in case anyone else is battling the same issue, but perhaps hasn't considered whether it is really necessary.

@marcelotduarte
Copy link
Owner

marcelotduarte commented Nov 7, 2023

PyQt5/6 and PySide2/6 QtWebEngine for Linux and Windows have been working for some time, including conda-forge (only the packages made available obviously).
Since PR #2025 (available in 6.15.7) I have made some adjustments to close this issue. Various patches to bdist_mac and hooks qt.
With PR #2124 I managed to close the loop for Qt6 webengine.
Now it's time for Qt5. I already have a version that I managed to make work but I had to duplicate files. And there are also some warnings:

Qt WebEngine resources not found at . Trying parent directory...
Installed Qt WebEngine locales directory not found at location /qtwebengine_locales. Trying application directory...
Qt WebEngine locales directory not found at location /Users/runner/work/freeze-test/freeze-test/samples/pyside2-simplebrowser/build/exe.macosx-11.7-x86_64-3.10/qtwebengine_locales. Trying fallback directory... Translations MAY NOT not be correct.
Path override failed for key ui::DIR_LOCALES and path '/Users/runner/.test_simplebrowser'
[1107/132211.682027:WARNING:resource_bundle_qt.cpp(115)] locale_file_path.empty() for locale 
2023-11-07 13:22:12.082 test_simplebrowser[2249:22049] Couldn't set selectedTextColor from default ()
2023-11-07 13:22:12.082 test_simplebrowser[2249:22049] Couldn't set selectedControlTextColor from default ()

I hope you'll be able to test it and give me some feedback.

You can test the Qt5 and Qt6 WebEngine in the latest development build:
pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
For conda-forge the command is:
conda install -y --no-channel-priority -S -c https://marcelotduarte.github.io/packages/conda cx_Freeze

Here the test of pyside2 macos11.7 py 3.10:
pyside2-simplebrowser-0-test_simplebrowser-macosx-11_7-x86_64-3_10

@jarathomas
Copy link

jarathomas commented Nov 8, 2023

Hello. Many thanks for your attention to this issue and for cx_Freeze in general (it is awesome)! I am using PyQt5 and the latest development build has fixed the problem for me. One side effect I noticed is that my find_data_file() function, described here, no longer worked, but was fixed with

#  datadir = os.path.dirname(sys.executable)  ## original code
datadir = os.path.join(os.path.dirname(sys.executable), "lib", "my_app_name")

@marcelotduarte
Copy link
Owner

Release 6.15.11 is out!

@marcelotduarte
Copy link
Owner

One side effect I noticed is that my find_data_file() function, described here, no longer worked, but was fixed with

@jarathomas #2169 must fix this issue, please test.
You can test the patch in the latest development build:
pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
For conda-forge the command is:
conda install -y --no-channel-priority -S -c https://marcelotduarte.github.io/packages/conda cx_Freeze

@jarathomas
Copy link

@marcelotduarte the fix (#2169) worked like a charm. Thanks again for this excellent tool and for attention to this issue!

@marcelotduarte
Copy link
Owner

Release 6.15.12 is out!

@cainesi
Copy link
Contributor

cainesi commented Jan 15, 2024

Thanks for keeping up the work on cxFreeze! Sorry I've been really busy at work recently and haven't had much time to help out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants