【发布时间】:2019-03-29 17:11:23
【问题描述】:
我在pygame上创建了一个基本画面,想编译发给朋友作为测试,文件在我的电脑上完美运行
但是,在我朋友的电脑上,它没有运行。
他的计算机上没有 python 或 pygame 版本,我正在使用仅安装了 pygame 和 cx_Freeze 的 Pycharm 项目解释器
游戏代码
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
)
【问题讨论】:
-
将绝对路径改为相对路径。