我想使用cx_freeze将我的hello_world.py更改为exe文件。
当我像这样运行cxfreeze时:
cxfreeze hello_world.py
我运行exe文件,它出现错误:
./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)
有谁知道如何解决这个问题?
运行以下将安装zlib的代码:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
在MacOS上,问题通常是XCode更新已删除了zlib。这些情况下的解决方案将运行:
xcode-select --install
在Linux机器上,您需要安装zlib,例如参见this answer。