Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 813
karl_TUM Avatar asked Jan 16 '18 19:01

karl_TUM


2 Answers

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

like image 165
yl_low Avatar answered Oct 15 '22 12:10

yl_low


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.

like image 44
YPCrumble Avatar answered Oct 15 '22 10:10

YPCrumble