Error while opening a python file converted into executable using cx_Freeze

亡梦爱人 提交于 2019-12-25 01:58:49

问题


I used cx_Freeze to convert a simple python program made using pygame and tkinter into an executable. However, when I try to open the .exe file.

This is the setup.py file which I used to convert the game into executable

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

    )

However when opening, I'm getting the following error:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00002e30 (most recent call first):

来源:https://stackoverflow.com/questions/55782641/error-while-opening-a-python-file-converted-into-executable-using-cx-freeze

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!