I would like to use cx_freeze to change my hello_world.py into exe file.
When I run cxfreeze like this:
cxfreeze hello_world.py
And I run the exe file, it comes the error:
./hello_world
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
File "/home/karl/anaconda3/lib/python3.6/encodings/__init__.py", line 31, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
Aborted (core dumped)
Does anyone know how to solve this?
Run the below code which will install zlib:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Thanks to the answer at https://stackoverflow.com/a/52756409/9162193
On MacOS the issue is often that an XCode update has removed zlib. The solution in these cases would be running:
xcode-select --install
On Linux machines you would need to install zlib, see for instance this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With