What could be the reason for fatal python error:initfsencoding:unable to load the file system codec?

What could be the reason for fatal python error:initfsencoding:unable to load the file system codec?

我正在使用 Python 3.7(64 位)并安装了 cx_Freeze 以将 .py 转换为 .exe。

我使用此命令提示符将 Python 脚本转换为可执行文件:

python [filename] build

它成功构建了可执行文件。但是当我执行我的 EXE 文件时,我只得到输出:

fatal python error:initfsencoding:unable to load the file system codec
ImportError: invalid flags 1530052318 in 'encoding'
Current thread 0X000013f8 :

如何解决并成功使用cx_Freeze制作可执行文件?

已在 4c18633 中修复。 问题是,对于 Python 3.7 的 x64 版本,由于 freezer.py 的 class 配置,它无法正常工作。 您需要转到 cx_Freezer 安装文件夹。如果您有虚拟环境,请转到您的环境文件夹 \lib\site-packages\cx_Freeze, 找到 freezer.py 并添加在提交中找到的代码。

您可以在 GitHub