我使用cx_Freeze将使用pygame和tkinter制作的简单python程序转换为可执行文件。但是,当我尝试打开.exe文件时。
这是我用来将游戏转换为可执行文件的setup.py文件
import cx_Freeze
import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR,
'tcl','tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl',
'tk8.6')
executables = [cx_Freeze.Executable("SnakeGame.py", icon="icon.png")]
cx_Freeze.setup(
name="SnakeGame by Param",
author="Param Dane",
options={"build_exe": {"packages":["pygame","tkinter"],
"include_files":["bgmenu.mp3","bg.mp3"]}},
version="0.1",
executables = executables
)
但是打开时,出现以下错误:
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00002e30 (most recent call first):