Error while opening a python file converted into e

2019-08-29 10:14发布

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):

0条回答
登录 后发表回答