Open mario-grgic opened 1 year ago
That /Applications/Xcode.app/Contents/Developer/usr/bin/python3
path above is very suspect. Not sure why that is picked up at all.
Did you find a solution ? I have the same issue.
@AymericFerreira No, I have not pursued this further, so I don't have a workaround.
+1
We finally managed to solve the issue, although the workaround might not be the same for everyone. However, I'll share our solution in case it helps.
Here was our full error log:
Python path configuration:
PYTHONHOME = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
PYTHONPATH = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
program name = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/MacOS/python’
isolated = 0
environment = 1
user site = 1
safe_path = 0
import site = 1
is in build tree = 0
stdlib dir = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/lib/python3.12’
sys._base_executable = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/MacOS/python’
sys.base_prefix = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
sys.base_exec_prefix = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
sys.platlibdir = ‘lib’
sys.executable = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/MacOS/python’
sys.prefix = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
sys.exec_prefix = ‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’
sys.path = [
‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources’,
‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/lib/python312.zip’,
‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/lib/python3.12’,
‘/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/lib/python3.12/lib-dynload’,
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
Traceback (most recent call last):
File “<frozen zipimport>“, line 518, in _get_decompress_func
ImportError: dlopen(/Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/zlib.cpython-312-darwin.so, 0x0002): Symbol not found: _adler32
Referenced from: <8C70B32E-A411-312F-AF6B-7C317ACCFF47> /Users/aymericferreira/Downloads/StitcherApp.app/Contents/Resources/zlib.cpython-312-darwin.so
Expected in: <9465408F-73C9-346B-986D-F8A0C8590651> /Users/aymericferreira/Downloads/StitcherApp.app/Contents/Frameworks/libz.1.3.1.dylib
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “<frozen zipimport>“, line 566, in _get_data
File “<frozen zipimport>“, line 521, in _get_decompress_func
zipimport.ZipImportError: can’t decompress data; zlib not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “<frozen zipimport>“, line 137, in get_code
File “<frozen zipimport>“, line 700, in _get_module_code
File “<frozen zipimport>“, line 568, in _get_data
zipimport.ZipImportError: can’t decompress data; zlib not available
In our case, the issue was related to the zlib library. The solution was to explicitly include zlib in the setup.py file as follows:
OPTIONS = {
"packages": ["zlib", ...],
"includes": ["zlib", ...]
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
I am using macOS 10.15.7 (Catalina) with Python 3.11.1 and py2app version 0.28.5. I have a simple tkinter python script that works when run from command line that I am trying to package as standalone Mac application.
My
setup.py
looks like this:then I run
python3 setup.py py2app
which generates a working application:When I run the generate application I get the error: