Cold Hands
Cold Hands

Reputation: 29

PyInstaller "pygame._view not found"

I've been working on a few projects recently using PyGame 1.9.3 and Python 3.4.4 and have come across an issue when I try to compile them with PyInstaller.

I thought maybe it was something wrong with my program such as an issue linking to images or fonts so I decided to create a very small test program and try to compile that and sure enough I'm getting the same errors.

"WARNING: Hidden import "pygame._view" not found!" and "Failed to execute test"

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

The program will load, show the white screen, and then instantly close with a command prompt window showing an error for only a split seconds before disappearing.

I've tried changing the filename to something different, switching directories, updating PyGame and PyInstaller, and importing pygame._view however it still gives me the missing module error and failed to execute error. I'm not sure what I'm doing wrong. Thank you very much in advance.

Upvotes: 0

Views: 2106

Answers (1)

eyllanesc
eyllanesc

Reputation: 244262

Perhaps the cmd and IDLE keep the window open state, I recommend that you use the while loop with a 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()

Upvotes: 0

Related Questions