PyInstaller“找不到pygame._view”

时间:2017-04-16 03:55:30

标签: python python-3.x pygame exe pyinstaller

我最近一直在使用PyGame 1.9.3和Python 3.4.4开发一些项目,当我尝试使用PyInstaller编译它们时遇到了一个问题。

我想也许我的程序出了问题,例如链接到图像或字体的问题,所以我决定创建一个非常小的测试程序并尝试编译它,果然我得到了同样的错误。

“警告:隐藏导入”pygame._view“找不到!”和“无法执行测试”

test.py:

import pygame

pygame.init()

colorWhite = (255, 255, 255)

winDisplay = pygame.display.set_mode((1280, 720))
pygame.display.set_caption("Test")
FPSClock = pygame.time.Clock()

def main():
    winDisplay.fill(colorWhite)
    pygame.display.update()
    FPSClock.tick(60)

if __name__ == "__main__":
    main()

warntest.txt:

missing module named 'win32com.gen_py' - imported by win32com, c:\python34\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_win32comgenpy.py
missing module named pyimod03_importers - imported by PyInstaller.loader.pyimod02_archive, c:\python34\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py
missing module named _dbm - imported by dbm.ndbm
missing module named gdbm - imported by anydbm, future.moves.dbm.gnu
missing module named _gdbm - imported by dbm.gnu
missing module named dumbdbm - imported by anydbm, future.moves.dbm.dumb
missing module named anydbm - imported by future.moves.dbm
missing module named dbhash - imported by anydbm
missing module named whichdb - imported by future.moves.dbm, anydbm
missing module named 'test.test_support' - imported by future.moves.test.support
missing module named 'test.support' - imported by future.moves.test.support
missing module named dummy_thread - imported by future.backports.misc
missing module named thread - imported by future.backports.misc, PyInstaller.loader.pyimod02_archive
missing module named __builtin__ - imported by pyparsing, future.builtins.misc, future.utils, past.types, past.builtins.noniterators, past.builtins, past.builtins.misc
missing module named future_builtins - imported by future.builtins.misc
missing module named _scproxy - imported by urllib.request, future.backports.urllib.request
missing module named multiprocessing.set_start_method - imported by multiprocessing, multiprocessing.spawn
missing module named multiprocessing.get_start_method - imported by multiprocessing, multiprocessing.spawn
missing module named multiprocessing.get_context - imported by multiprocessing, multiprocessing.pool, multiprocessing.managers, multiprocessing.sharedctypes
missing module named multiprocessing.TimeoutError - imported by multiprocessing, multiprocessing.pool
missing module named multiprocessing.AuthenticationError - imported by multiprocessing, multiprocessing.connection
missing module named multiprocessing.BufferTooShort - imported by multiprocessing, multiprocessing.connection
missing module named UserDict - imported by PyInstaller.compat
missing module named 'PyInstaller.lib.macholib.compat' - imported by PyInstaller.lib.macholib.MachO
missing module named _pkgutil - imported by PyInstaller.lib.modulegraph.modulegraph
missing module named urllib.pathname2url - imported by urllib, PyInstaller.lib.modulegraph.modulegraph
missing module named StringIO - imported by six, PyInstaller.lib.modulegraph.util, PyInstaller.lib.modulegraph.zipio, PyInstaller.lib.modulegraph.modulegraph
missing module named pyimod00_crypto_key - imported by PyInstaller.loader.pyimod02_archive
missing module named Crypto - imported by PyInstaller.building.makespec
missing module named _sysconfigdata - imported by sysconfig
missing module named 'com.sun' - imported by appdirs
missing module named com - imported by appdirs
missing module named ordereddict - imported by pyparsing
missing module named six.moves.filter - imported by six.moves, pkg_resources
missing module named 'six.moves.urllib' - imported by 'six.moves.urllib'
missing module named six.moves.map - imported by six.moves, pkg_resources
runtime module named six.moves - imported by pkg_resources, 'six.moves.urllib'
missing module named resource - imported by posix, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named posix - imported by os, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named _posixsubprocess - imported by subprocess, multiprocessing.util, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named 'org.python' - imported by pickle, xml.sax, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named ce - imported by os, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named readline - imported by cmd, code, pdb, C:\Users\Shiloh\Desktop\TestProgram\test.py
excluded module named _frozen_importlib - imported by importlib, PyInstaller.loader.pyimod02_archive, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named _winreg - imported by platform, pygame, pygame.sysfont, appdirs, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named java - imported by platform, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named 'java.lang' - imported by platform, xml.sax._exceptions, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named vms_lib - imported by platform, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named termios - imported by tty, getpass, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named _dummy_threading - imported by dummy_threading, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named grp - imported by tarfile, shutil, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named org - imported by copy, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named pwd - imported by posixpath, tarfile, shutil, http.server, webbrowser, distutils.util, getpass, C:\Users\Shiloh\Desktop\TestProgram\test.py
missing module named copy_reg - imported by cStringIO, pygame
missing module named 'pygame._view' - imported by pygame
missing module named MacOS - imported by pygame.macosx
missing module named macresource - imported by MacOS
missing module named pygame.sdlmain_osx - imported by pygame, pygame.macosx
missing module named OpenGL - imported by pygame
missing module named numpy - imported by pygame._numpysurfarray, pygame._numpysndarray, pygame
missing module named 'pygame.movie' - imported by pygame
missing module named pygame.SRCALPHA - imported by pygame, pygame.ftfont
missing module named Queue - imported by pygame.threads
missing module named Py25Queue - imported by pygame.threads
missing module named cStringIO - imported by pygame.compat

程序将加载,显示白色屏幕,然后立即关闭,并在命令提示窗口中显示错误,仅在几秒钟内消失。

我已经尝试将文件名更改为不同的东西,切换目录,更新PyGame和PyInstaller,以及导入pygame._view但是它仍然给我丢失的模块错误并且无法执行错误。我不确定我做错了什么。非常感谢你提前。

1 个答案:

答案 0 :(得分:0)

也许IDLEflag保持窗口处于打开状态,我建议您使用带有import pygame pygame.init() colorWhite = (255, 255, 255) winDisplay = pygame.display.set_mode((1280, 720)) pygame.display.set_caption("Test") FPSClock = pygame.time.Clock() def main(): running = True while running: winDisplay.fill(colorWhite) pygame.display.update() FPSClock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() if __name__ == "__main__": main() 的while循环。

{{1}}