【问题标题】:Py2EXE Compile Error using PygamePy2EXE 使用 Pygame 编译错误
【发布时间】:2012-08-12 21:12:02
【问题描述】:

我只是使用Py2exe将一个简单的pygame程序编译成可执行文件,但出现以下错误:

*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included, you may or
may not need to distribute them.

Make sure you have the license if you distribute any of them, and make sure you
don't distribute files belonging to the operating system.

    OLEAUT32.dll - C:\windows\system32\OLEAUT32.dll
    USER32.dll - C:\windows\system32\USER32.dll
    IMM32.dll - C:\windows\system32\IMM32.dll
    SHELL32.dll - C:\windows\system32\SHELL32.dll
    ole32.dll - C:\windows\system32\ole32.dll
    COMDLG32.dll - C:\windows\system32\COMDLG32.dll
    COMCTL32.dll - C:\windows\system32\COMCTL32.dll
    ADVAPI32.DLL - C:\windows\system32\ADVAPI32.DLL
    WS2_32.dll - C:\windows\system32\WS2_32.dll
    GDI32.dll - C:\windows\system32\GDI32.dll
    WINMM.DLL - C:\windows\system32\WINMM.DLL
    KERNEL32.dll - C:\windows\system32\KERNEL32.dll
    SDL_ttf.dll - C:\Python27\lib\site-packages\pygame\SDL_ttf.dll
    libogg-0.dll - C:\Python27\lib\site-packages\pygame\libogg-0.dll

当我尝试运行创建的 .exe 时,它​​没有运行。我对 Pygame 很熟悉,但 Py2exe 对我来说是全新的。感谢您提供任何帮助,因为我整个上午都在网上寻找解决方案。

这是我尝试运行时出现的内容:

test.exe:1: RuntimeWarning: import display: No module named _view
    (ImportError: No module named _view)
    test.exe:1: RuntimeWarning: import draw: No module named _view
    (ImportError: No module named _view)
    test.exe:1: RuntimeWarning: import image: No module named _view
    (ImportError: No module named _view)
    test.exe:1: RuntimeWarning: import pixelcopy: No module named _view
    (ImportError: No module named _view)
    test.exe:1: RuntimeWarning: import transform: No module named _view
    (ImportError: No module named _view)
    Traceback (most recent call last):
      File "test.py", line 7, in <module>
      File "pygame\__init__.pyc", line 70, in __getattr__
    NotImplementedError: display module not available
    (ImportError: No module named _view)

【问题讨论】:

  • 为您创建了一个可执行文件,对吗?尝试从命令提示符运行它。它给你什么错误?请注意,您发布的内容不一定是错误消息,它只是提醒您需要将 .DLL 文件包含在为您创建的可执行文件中,以便在其他机器上运行(因为该机器可能你没有相同的 DLL)。
  • 你的 setup.py 是什么样的?您是否使用了正确的 py2exe pygame 配方? Py2exe 现在已经很老了
  • @jdi 这是每一行:from distutils.core import setupimport py2exesetup(console=['test.py'])
  • @MarkHildreth 我更新了上述问题中的错误。我得到了在命令提示符和外部运行它的消息。是的,没错,那么你将如何告诉 Python 包含 DLL?
  • 如果手动import pygame._view会怎样?这似乎是一个常见的错误。 (我也改用 pyInstaller 而不是 py2app/py2exe/freeze)。

标签: python compilation compiler-errors pygame py2exe


【解决方案1】:

尝试将其添加到您的主程序中:

from pygame.locals import *

它解决了我在编译pygame时遇到的问题

【讨论】:

    猜你喜欢
    • 2015-05-04
    • 1970-01-01
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多