我已经在pygame上创建了一个基本屏幕,并希望将其编译为发送给朋友作为测试,并且该文件在我的计算机上运行完美
但是,在我的朋友计算机上,它没有运行。
他的计算机上没有python或pygame的版本,我正在使用Pycharm Project解释器,只安装了pygame和cx_Freeze
游戏代码
import sys, pygame
size = 600, 600
pygame.init()
screen = pygame.display.set_mode(size)
colour = (70, 70, 70)
while 1:
screen.fill(colour)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
构建文件
import cx_Freeze
import os
os.environ['TCL_LIBRARY'] = r'C:\Users\jls45\Documents\Curse\code\BigBossBattleGame\venv\Scripts\tcl86t.dll'
os.environ['TK_LIBRARY'] = r'C:\Users\jls45\Documents\Curse\code\BigBossBattleGame\venv\Scripts\tk86t.dll'
executables = [cx_Freeze.Executable("Main.py")]
cx_Freeze.setup(
name="Test",
options={"build_exe": {"packages":["pygame"],
"include_files":["test.png"]}},
executables = executables
)
由于你的朋友没有Python或pygame,他们可能也没有tk / tcl。您需要将这些.dll与您的可执行文件打包在一起。
"include_files":[
"test.png",
r'C:\Users\jls45\Documents\Curse\code\BigBossBattleGame\venv\Scripts\tcl86t.dll',
r'C:\Users\jls45\Documents\Curse\code\BigBossBattleGame\venv\Scripts\tk86t.dll',
]