zipimport.ZipImportError: can't decompress data; zlib not available

karl_TUM picture karl_TUM · Jan 16, 2018 · Viewed 9.3k times · Source

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?

Answer

yl_low picture yl_low · Nov 9, 2018

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