我一直在拼命地尝试将我的Python Pygame程序编译成独立的可执行文件,但一直没有成功。PyInstaller与Pygame不兼容,Nuitka无法制作有效的独立文件,而cx_Freeze似乎是最好的选择。然而,当我使用我的
我的
setup.py
进行编译时,它生成了一组文件,但main
可执行文件无法运行。我的
setup.py
如下:import sys
import cx_Freeze
executables = [cx_Freeze.Executable("main.py")]
images =["assets/images/1.png","assets/images/2.png","assets/images/3.png","assets/images/4.png","assets/images/5.png","assets/images/6.png","assets/images/7.png","assets/images/8.png","assets/images/tile.png","assets/images/mark.png","assets/images/mine.png","assets/images/overlay.png","assets/images/overlay_2.png","assets/images/background.png"]
cx_Freeze.setup(
name="Minesweeper",
options={"build_exe": {"packages":["pygame"],
"include_files":images}},
executables = executables
)
主文件main.py
引用了其他的Python文件;这会有影响吗?
非常感谢。
编辑: 根据请求,平台为Linux(Ubuntu 14.04); Python版本为3.4.3; cx_Freeze是cxfreeze 5.0,通过pip下载。 准确的错误信息如下:
Fatal Python error: Py_Initialize: Unable to get locale encoding
Traceback (most recent call last):
File "usr/lib/python3.4/encodings/__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
Aborted (core dumped)