简体   繁体   English

用cx_freeze生成的可执行文件在关闭前会打开一会儿

[英]Executable generated with cx_freeze opens for an instant before closing

So I made an executable of my python script using cx_freeze but when I open it the window only stays for a fraction of a second before disappearing. 因此,我使用cx_freeze制作了python脚本的可执行文件,但是当我打开它时,窗口只消失了一秒钟,然后消失了。 I opened it directly with cmd and this is the error it displayed: 我直接用cmd打开它,这是它显示的错误:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in     <module>
    try: import pygame.display
  File "ExtensionLoader_pygame_display.py", line 22, in <module>
  File "ExtensionLoader_pygame_display.py", line 14, in __bootstrap__
  File "ExtensionLoader_pygame_surface.py", line 22, in <module>
  File "ExtensionLoader_pygame_surface.py", line 14, in __bootstrap__
ImportError: No module named _view

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py",     line 27, in <module>
    exec(code, m.__dict__)
  File "c:\users\admin\desktop\project2.py", line 1, in <module>
    import pygame
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in     <module>
    except (ImportError,IOError):display=MissingModule("display",     geterror(), 1)
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in     __init__
    self.warn()
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
    warnings.warn(message, RuntimeWarning, level)
  File "C:\Python\32-bit\3.2\lib\warnings.py", line 18, in showwarning
  File "C:\Python\32-bit\3.2\lib\warnings.py", line 25, in formatwarning
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 15, in getline
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 41, in getlines
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 127, in updatecache
  File "C:\Python\32-bit\3.2\lib\codecs.py", line 300, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0x90 in position 2:     invalid start byte

When I compiled the executable it said that it hadn't imported several files from pygame, but "this may not be a problem as they may not be needed." 当我编译可执行文件时,它说它没有从pygame导入几个文件,但是“这可能不是问题,因为可能不需要它们。” I'm guessing this error is a product of those files not being imported but I don't know how to fix that. 我猜这个错误是由于这些文件未导入而导致的,但我不知道如何解决。

I solved the problem. 我解决了问题。 It seemed to be an issue with the version of Python and Pygame that I had, and after getting a more recent version of both everything worked just fine. 我所拥有的Python和Pygame版本似乎存在问题,并且在获得更新的版本后,一切都正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM