我无法使用cx_freeze编译pygame游戏

时间:2015-05-13 00:15:13

标签: python compilation pygame cx-freeze linuxmint

我正在尝试编译我在python中制作的游戏。我正在使用Python 2.7和Pygame 1.9.1,当我在Linux Mint 14上的终端(〜$ python game.py)中打开它时,它可以工作。我想让它在没有Python的计算机上运行Pygame已安装。我尝试使用cx_freeze(〜$ python setup.py build)编译脚本game.py。它创建了一个文件夹,但游戏无法启动。当我在终端(./game)中打开它时,我收到了一些错误:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/cx_Freeze/initscripts/Console.py", line 29, in <module>
    exec code in m.__dict__
  File "game.py", line 24, in <module>
  File "/usr/lib/python2.7/dist-packages/pygame/sysfont.py", line 555, in SysFont
    initsysfonts()
  File "/usr/lib/python2.7/dist-packages/pygame/sysfont.py", line 524, in initsysfonts
    fonts = initsysfonts_unix()
  File "/usr/lib/python2.7/dist-packages/pygame/sysfont.py", line 460, in initsysfonts_unix
    entries = toascii(flout)
  File "/usr/lib/python2.7/dist-packages/pygame/sysfont.py", line 33, in toascii
    return raw.decode('ascii', 'ignore')
LookupError: unknown encoding: ascii

如何解决?

setup.py文件是:

from cx_Freeze import setup, Executable
setup( name = "Game",
       version = "1.0",
       description = "Igra",
       executables = [Executable("game.py")] )

game.py有180行,也许它没有写清楚所以我希望我不必把它放在这里,但我用过:

import pygame
import random
import time
...
open("save.txt", "r") #maybe this is not working in pygame
...
pygame.font.SysFont("arial", 15) #maybe that's the problem
#or something else is the problem

感谢您的帮助。如果有必要,我会将脚本game.py放在这里。

0 个答案:

没有答案