2017-04-16 87 views
-1

我一直在研究最近使用PyGame 1.9.3和Python 3.4.4的几个项目,并且在尝试使用PyInstaller编译它们时遇到了一个问题。PyInstaller“pygame._view not found”

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

“WARNING:Hidden import”pygame._view“not found!”和 “无法执行测试”

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,但它仍然给我缺少的模块错误,并且无法执行错误。我不确定我做错了什么。非常感谢你提前。

+0

这不是一个错误,它是一个警告。如果你从python运行你的文件具有相同的行为,请检查你的初始代码 – eyllanesc

+0

当我运行.py文件而不编译它时,程序运行时没有任何问题。 –

+0

你在终端或IDE上运行吗? – eyllanesc

回答

0

也许cmdIDLE保持窗口打开状态,我建议您使用while循环与flag

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() 
+0

谢谢!我觉得很傻哈哈。我确实有一个问题,通常我做类似的事情,但我只是把“而真”:而不是你做了什么。他们的功能不同吗? –

+0

它是相似的,因为我假设你使用'sys.exit()'或'break'。 – eyllanesc