所以我使用cx_freeze创建了我的python脚本的可执行文件但是当我打开它时,窗口只停留了几分之一秒才消失。我用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
当我编译可执行文件时,它说它没有从pygame导入多个文件,但“这可能不是问题,因为它们可能不需要。”我猜这个错误是那些没有导入的文件的产物,但我不知道如何修复它。
答案 0 :(得分:0)
我解决了这个问题。我的Python和Pygame版本似乎是一个问题,在获得更新版本的两个版本后,一切工作都很顺利。