ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
340 stars 36 forks source link

ImportError: dlopen(.../Contents/Resources/lib/python3.9/wx/_core.cpython-39-darwin.so, 2): bad rebase type 4 in .../Contents/MacOS/../Frameworks/liblzma.5.dylib #317

Open Deuchnord opened 3 years ago

Deuchnord commented 3 years ago

I'm trying to package my wxPython application, but facing the following error when trying to execute it:

Traceback (most recent call last):
  File "/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/__boot__.py", line 101, in <module>
    _run()
  File "/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/__boot__.py", line 84, in _run
    exec(compile(source, path, "exec"), globals(), globals())
  File "/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/kosmorro-gui", line 3, in <module>
    from kosmorrolib.gui import mainwindow
  File "<frozen zipimport>", line 259, in load_module
  File "kosmorrolib/gui/mainwindow.pyc", line 2, in <module>
  File "/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/lib/python3.9/wx/__init__.py", line 17, in <module>
    from wx.core import *
  File "/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/lib/python3.9/wx/core.py", line 12, in <module>
    from ._core import *
ImportError: dlopen(/Users/jerome/workspace/kosmorro/kosmorro/dist/Kosmorro.app/Contents/Resources/lib/python3.9/wx/_core.cpython-39-darwin.so, 2): bad rebase type 4 in /Users/jerome/workspace/kosmorro/kosmorro/./dist/Kosmorro.app/Contents/MacOS/../Frameworks/liblzma.5.dylib
2020-11-29 12:10:31.929 kosmorro[4138:95553] Kosmorro Error

My setup.py:

#!/usr/bin/env python3

from setuptools import setup

APP = ['kosmorro-gui']
DATA_FILES = []
OPTIONS = {
    'plist': 'build/distrib/darwin/Info.plist',
    'packages': ','.join(['skyfield>=1.21.0,<2.0.0', 'tabulate', 'numpy>=1.17.0,<2.0.0',
                          'termcolor', 'python-dateutil', 'wx'])
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

My kosmorro-gui:

#!/usr/bin/python3

from kosmorrolib.gui import mainwindow

def main():
    mainwindow.start()

if __name__ == '__main__':
    main()

kosmorrolib is a package included in my app. If needed, the mainwindow module can be found here.

I'm running macOS 11.0.1 and Python 3.9.0

What does this error mean, and how can I fix it?

hasii2011 commented 3 years ago

I'd like to know the answer to this one also.

ronaldoussoren commented 3 years ago

I'll see if I can reproduce this locally.

How did you install Python and wxPython (python.org installer, homebrew, ...)?

hasii2011 commented 3 years ago

For me I use pyenv from homebrew; Then create a virtual environment like

python3 -m venv venv-pyenv-3.9.0 and 
source ./venv-pyenv-3.9.0/bin/activate
pip3 install wxpython

the latest stable wxpython

Deuchnord commented 3 years ago

On my side, it is installed globally with PIP:

pip install -g wxPython
Deuchnord commented 3 years ago

Hi @ronaldoussoren, did you manage to reproduce the error, or do you need more information? 🙂

If needed, I wrote a reproducer that opens an empty window: https://github.com/Deuchnord/py2app-wx-issue-bad-rebase-reproducer

When invoked with python3 app.py, the empty window opens as expected. But when the app is built, the app fails opening.