Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Pygame时Py2EXE编译错误_Python_Compilation_Compiler Errors_Pygame_Py2exe - Fatal编程技术网

Python 使用Pygame时Py2EXE编译错误

Python 使用Pygame时Py2EXE编译错误,python,compilation,compiler-errors,pygame,py2exe,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, a

我只是使用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)
test.exe:1:运行时警告:导入显示:没有名为的模块\u视图
(导入错误:没有名为_view的模块)
test.exe:1:运行时警告:导入绘图:没有名为_view的模块
(导入错误:没有名为_view的模块)
test.exe:1:运行时警告:导入映像:没有名为\u视图的模块
(导入错误:没有名为_view的模块)
test.exe:1:运行时警告:导入像素复制:没有名为_view的模块
(导入错误:没有名为_view的模块)
test.exe:1:运行时警告:导入转换:没有名为_view的模块
(导入错误:没有名为_view的模块)
回溯(最近一次呼叫最后一次):
文件“test.py”,第7行,在
文件“pygame\\ uuuuu init\ uuuuuu.pyc”,第70行,在\uuuu getattr中__
未实现错误:显示模块不可用
(导入错误:没有名为_view的模块)

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

from pygame.locals import *

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

尝试将此添加到主程序:

from pygame.locals import *

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

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