Python pyinstaller创建的程序崩溃

Python pyinstaller创建的程序崩溃,python,pygame,pyinstaller,Python,Pygame,Pyinstaller,如果我初始化“pyinstaller main.py”并将项目的所有文件移动到.exe方向,它将统计。我可以在控制台中创建的菜单中执行某些操作 但当我选择开始时,游戏就停止了。我在StackOverflow上读到关于更改项目中声明字体的方式的文章,但我认为这还不够。整个游戏循环都在一个名为game()的函数中,因此下面我将发布此函数的代码 有人能帮我解决这个问题吗 我曾尝试使用pyinstaller的GUI版本,但效果不佳 def play(self): self.reset()

如果我初始化
“pyinstaller main.p
y”并将项目的所有文件移动到
.exe
方向,它将统计。我可以在控制台中创建的菜单中执行某些操作

但当我选择开始时,游戏就停止了。我在StackOverflow上读到关于更改项目中声明字体的方式的文章,但我认为这还不够。整个游戏循环都在一个名为
game()
的函数中,因此下面我将发布此函数的代码

有人能帮我解决这个问题吗

我曾尝试使用
pyinstaller
的GUI版本,但效果不佳

def play(self):
    self.reset()
    self.random_field()

    while self.game:
        self.screen.fill(self.background_color_play)
        direction = self.event_catcher()
        if direction:
            self.move(direction)
            if direction != "back":
                self.random_field()
                if self.score > self.best:
                    self.best = self.score

        for i in range(self.size*self.size):
            self.tiles[i].update_color()
            pygame.draw.rect(self.screen, self.tiles[i].color, [self.tiles[i].x1, self.tiles[i].y1,
                                                                self.tiles[i].x2, self.tiles[i].y2])
            if self.tiles[i].value:
                self.message_display(text=str(self.tiles[i].value), x=(2*self.tiles[i].x1+self.tiles[i].x2)/2,
                                     y=(2*self.tiles[i].y1+self.tiles[i].y2)/2, font_size=100,
                                     color=self.tiles[i].font_color, font="Clear Sans Bold")

        # UNDO
        if self.size_of_stack:
            self.message_display(text=Screen.req_word("undo", self.lang)+": {}".format(self.stack.size()//len(self.tiles)),
                                 x=20, y=(self.screen_height-self.screen_width+10)/2, font_size=30,
                                 color=(69, 69, 69), pos="left")
        else:
            self.message_display(text=Screen.req_word("undo", self.lang)+": 0",
                                 x=20, y=(self.screen_height-self.screen_width+10)/2, font_size=30,
                                 color=(69, 69, 69), pos="left")

        # SCORE
        self.message_display(text=Screen.req_word("score", self.lang)+": {}".format(self.score),
                             x=self.screen_width*0.5, y=(self.screen_height-self.screen_width+10)/2, font_size=30,
                             color=(69, 69, 69))

        # BEST SCORE
        self.message_display(text=Screen.req_word("best", self.lang)+": {}".format(self.best),
                             x=self.screen_width-20, y=(self.screen_height-self.screen_width+10)/2, font_size=30,
                             color=(69, 69, 69), pos="right")

        self.clock.tick(self.fps)
        pygame.display.update()

    self.main_menu()
我希望它不会在另一台没有安装python的计算机上崩溃。如果需要,请提供完整的代码 我的.spec文件:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['main.py'],
             pathex=['C:\\Projekty Pythona\\2048'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

今天,我将尝试查找有问题的语句

如果从命令提示符启动可执行文件,您是否看到有用的回溯?我猜你的问题是加载资源。您使用的
.spec
文件是什么?请考虑制作A,让别人更容易帮助你。谢谢,一切都适合我,问题在字体上: