Cx_Freeze可执行不pygame的工作(Cx_Freeze executable doesn&

2019-09-16 09:26发布

我有我的Python程序创建可执行的麻烦cx_freeze.I是在Windows(XP)和我的程序使用Tkinter的,Pygame的(随机),并在Python 3.2是编码。 我曾尝试创建一个下蒸馏,并从命令提示符下运行:

cxfreeze --target-dir dist

在这两个我得到这个错误:

    Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in <module>

    try: import pygame.display
  File "ExtensionLoader_pygame_display.py", line 12, in <module>
  File "ExtensionLoader_pygame_surface.py", line 12, in <module>
ImportError: No module named _view

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
    exec(code, m.__dict__)
  File "BallGame.pyw", line 1, in <module>
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in <module>

    except (ImportError,IOError):display=MissingModule("display", geterror(), 1)

  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in __init__
    self.warn()
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
    warnings.warn(message, RuntimeWarning, level)
  File "C:\Python32\lib\warnings.py", line 18, in showwarning
    file.write(formatwarning(message, category, filename, lineno, line))
  File "C:\Python32\lib\warnings.py", line 25, in formatwarning
    line = linecache.getline(filename, lineno) if line is None else line
  File "C:\Python32\lib\linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python32\lib\linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python32\lib\linecache.py", line 127, in updatecache
    lines = fp.readlines()
  File "C:\Python32\lib\codecs.py", line 300, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x90 in position 2: invalid s
tart byte

请你能告诉我如何解决它,或建议不同的软件把我的Python脚本到可执行文件。 任何帮助是极大的赞赏。 提前致谢!

Answer 1:

您需要运行import pygame._view在脚本的开始。



文章来源: Cx_Freeze executable doesn't work with pygame