【发布时间】:2021-04-17 11:12:03
【问题描述】:
我用pygame创建了一个小游戏,想和朋友分享,所以我想把它转换成.exe文件。我正在使用 python 3.9.1、pygame 2.0.1 和 pyinstaller 4.1,我的操作系统是 Win 10。 尝试运行创建的 exe 文件后,不会出现任何窗口,控制台也只会出现一瞬间。 我读到,pyinstaller 可能对包含的文件有问题,因此我用一个更简单的例子对其进行了测试:
import pygame
pygame.init()
surf = pygame.display.set_mode((600, 600))
while True:
for e in pygame.event.get():
if e.type == pygame.QUIT:
pygame.quit()
break
pygame.display.update()
这里我有同样的问题,现在窗口出现了,当我通过 cmd 运行它时,我得到的唯一错误是
在测试其他脚本时出现以下错误:
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: unknown encoding: utf-8
Current thread 0x00001f4c (most recent call first):
<no Python frame>
编辑 在 python 3.8.6 中使用 pyinstaller 似乎可以工作
【问题讨论】:
-
你能分享你在pyinstaller中使用的命令吗?它应该类似于以下示例:stackoverflow.com/questions/48757977/…
-
我使用的命令是“pyinstaller --onefile scriptname.py”,我在 python 3.7 中使用过这个命令,当时(差不多一年前)运行良好
标签: python pygame pyinstaller