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

Error while packaging PySide2 based application on mac #2154

Closed
programus opened this issue Dec 4, 2023 · 5 comments · Fixed by #2172
Closed

Error while packaging PySide2 based application on mac #2154

programus opened this issue Dec 4, 2023 · 5 comments · Fixed by #2172

Comments

@programus
Copy link

Prerequisite

  • Make sure no duplicated issue has already been reported. You should look for closed issues, too.
  • Make sure you are not asking us to help to solve your specific issue. GitHub issues are opened mainly for development purposes. If you want to ask someone to help to solve your problem, go to some community site like StackOverflow, etc.
  • Make sure your problem is not derived from packaging (e.g. Homebrew).

Describe the bug
While packaging a PySide2 (Qt) based application on mac, there is an error said cannot find some file in Postgres.app even the application does not use PostgreSQL DB.

Error message:

error: [Errno 2] No such file or directory: '/Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib'

To Reproduce

I created a minimal project to reproduce the problem: https://github.com/programus/cx-freeze-test

Here are the production steps (python version is 3.10.12):

git clone https://github.com/programus/cx-freeze-test.git
cd cx-freeze-test
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
python setup.py build

Wait a while and you will get the same error.

ps. cx-Freeze 6.6 works without this error and is able to generate dmg file and app file properly.

Expected behavior
I expected the job success and the dmg file and app file are generated properly.

Screenshots
N/A

Desktop (please complete the following information):

  • Platform information: macOS Sonoma 14.1.2
  • OS architecture: Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64
  • cx_Freeze version: 6.15.11
  • Python version: 3.10.12

Additional context
N/A

@marcelotduarte
Copy link
Owner

Try to adapt your setup to use zip_include_packages like in our pyside2 sample:
https://github.com/marcelotduarte/cx_Freeze/blob/main/samples/pyside2/setup.py#L54

@programus
Copy link
Author

programus commented Dec 5, 2023

Thank you for your response. I now can build the .app and .dmg file after added zip_include_packages. But the app does not start. I tried to run it from inside of the package on console. It ends with this error:

❯ pwd
xxxxxx/cx-freeze-test/build/cx-freeze test.app/Contents/MacOS

❯ ./main
Traceback (most recent call last):
  File "/Users/<user-name>/workplace/Work/selfWorks/cx-freeze-test/venv/lib/python3.10/site-packages/cx_Freeze/initscripts/__startup__.py", line 124, in run
    module_init.run(name + "__main__")
  File "/Users/<user-name>/workplace/Work/selfWorks/cx-freeze-test/venv/lib/python3.10/site-packages/cx_Freeze/initscripts/console.py", line 16, in run
    exec(code, module_main.__dict__)
  File "main.py", line 11, in <module>
ImportError: dlopen(/Users/<user-name>/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/MacOS/lib/PySide2/QtWidgets.abi3.so, 0x0002): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets
  Referenced from: <C6F1FFFF-9D14-37F5-A9A2-0ABBB917DDAC> /Users/<user-name>/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/Resources/lib/PySide2/QtWidgets.abi3.so
  Reason: tried: '/Users/<user-name>/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/Resources/lib/PySide2/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/Resources/lib/PySide2/Qt/lib/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/Resources/lib/PySide2/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/Resources/lib/PySide2/Qt/lib/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx-freeze-test/build/cx-freeze test.app/Contents/MacOS/lib/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/Library/Frameworks/QtWidgets.framework/Versions/5/QtWidgets' (no such file), '/System/Library/Frameworks/QtWidgets.framework/Versions/5/QtWidgets' (no such file, not in dyld cache)

I also cloned the cx_Freeze repo and tried the PySide2 sample, I got a similar error.

❯ ./test_pyside2
Traceback (most recent call last):
  File "/Users/<user-name>/workplace/Work/selfWorks/cx_Freeze/venv/lib/python3.10/site-packages/cx_Freeze/initscripts/__startup__.py", line 124, in run
    module_init.run(name + "__main__")
  File "/Users/<user-name>/workplace/Work/selfWorks/cx_Freeze/venv/lib/python3.10/site-packages/cx_Freeze/initscripts/console.py", line 16, in run
    exec(code, module_main.__dict__)
  File "test_pyside2.py", line 7, in <module>
ImportError: dlopen(/Users/<user-name>/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/MacOS/lib/PySide2/QtCore.abi3.so, 0x0002): Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
  Referenced from: <33B37FBA-9774-3F27-9496-B46CCDAC6A98> /Users/<user-name>/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/Resources/lib/PySide2/QtCore.abi3.so
  Reason: tried: '/Users/<user-name>/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/Resources/lib/PySide2/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/Resources/lib/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/Resources/lib/PySide2/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/Resources/lib/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/wangyuan/workplace/Work/selfWorks/cx_Freeze/samples/pyside2/build/simple_PySide2-0.5.app/Contents/MacOS/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Library/Frameworks/QtCore.framework/Versions/5/QtCore' (no such file), '/System/Library/Frameworks/QtCore.framework/Versions/5/QtCore' (no such file, not in dyld cache)

I tried on python 3.10.12 and python 3.8.18. Both have the same error. Could you help me on this?

I have updated the minimal reproducing project.

@marcelotduarte
Copy link
Owner

marcelotduarte commented Dec 8, 2023

The pyside2 sample was tested in CI (py38-3.10, macos 11.7) and tested using homebrew python 3.10 macos 11.0 recently (about 2 weeks ago), using cx_Freeze 6.15.10.
Please test with the cx_Freeze 6.15.10.

@programus
Copy link
Author

I tested with the cx_Freeze 6.15.10 and it works both the sample and my minimal project! Thank you for your help!

But I still hope you can fix this problem in the future versions so I can update the version.

@marcelotduarte
Copy link
Owner

Release 6.15.12 is 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.

2 participants