-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Comments
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.) |
I've run this, but unfortunately it s not very illuminating. The component that does not load, 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: Here's the output of
Here is the (lengthy) recursive directory listing of all of the files in the frozen result app - 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 |
I was looking at how pyinstaller handles this and it looks like they set an environment variable, 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 |
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" |
For what it's worth, I got the test script working by:
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. |
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. |
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. |
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! |
I mean a temporary workaround. First, I tested the sample (of your gist) on Ubuntu, and: 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.
Apparently, there are no errors. I did same test with bdist_mac. Can you try a clean build? |
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 I can also run the app successfully with just 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 Could you try to run the Thanks again. |
No, sorry, I mean "I cannot" |
Yes, now I got the error 😅 The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile. |
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:
|
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.
|
Same Problem here only with a Windows 10 Machine ! pls help |
Are you including pyqt in the zip file? |
Hi , i tryed many things from cx_Freeze import * company_name = 'test' includes = ['atexit','PyQt5'] packages = ['PyQt5',] i try to build a installer with , python setup.py bdist_msi but evertime exe and installer not working |
ok.ok i see my mistake , i write PyQt5 in zip_exclude_packages and now it works . Thx :) |
now .exe is working but installer isn`t , any help ? |
Can you give more details about how the installer is not working? |
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 |
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
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. |
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. |
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. |
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).
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: |
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
|
Release 6.15.11 is out! |
@jarathomas #2169 must fix this issue, please test. |
@marcelotduarte the fix (#2169) worked like a charm. Thanks again for this excellent tool and for attention to this issue! |
Release 6.15.12 is out! |
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. |
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) usingcx_Freeze 6.3
,Python 3.7
, andPyQt 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
andPyQt 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
duringbdist_mac
processing. The program in theexe.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 viapip install PyQtWebEngine
. I have also tried this with every released version of cx_freeze from 6.4 onward, including6.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 andpip install cx_freeze pyqtwebengine
followed bypython 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.
The text was updated successfully, but these errors were encountered: