使用Pygame进行Py2EXE编译错误

时间:2012-08-12 21:12:02

标签: python compilation compiler-errors pygame py2exe

我只是使用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)

1 个答案:

答案 0 :(得分:0)

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

from pygame.locals import *

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