当它被编译为 exe 时,我遇到了 ursina 的问题

i have problem with ursina when it get compiled to exe

我开始使用 ursina 创建射击游戏,并尝试使用 pyinstaller 从中获取 exe。在我得到 exe 后,当我 运行 应用程序时,它显示错误(o 我用 ursina 编写了一个新游戏,但是 我明白了:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
  File "ursina\main.py", line 28, in __init__
  File "direct\showbase\ShowBase.py", line 339, in __init__
  File "direct\showbase\ShowBase.py", line 1024, in openDefaultWindow
  File "direct\showbase\ShowBase.py", line 1059, in openMainWindow
  File "direct\showbase\ShowBase.py", line 769, in openWindow
  File "direct\showbase\ShowBase.py", line 749, in <lambda>
  File "direct\showbase\ShowBase.py", line 821, in _doOpenWindow
  File "direct\showbase\ShowBase.py", line 650, in makeDefaultPipe
  File "direct\directnotify\Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.

我的代码:

from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from ursina.shaders import lit_with_shadows_shader

app = Ursina()

ground = Entity(model='plane', collider='box', scale=64, texture='grass', texture_scale=(4,4))

editor_camera = EditorCamera(enabled=False, ignore_paused=True)
player = FirstPersonController()


for i in range(16):
    Entity(model='cube', origin_y=-.5, scale=2, texture='brick', texture_scale=(1,2),
        x=random.uniform(-8,8),
        z=random.uniform(-8,8) + 8,
        collider='box',
        scale_y = random.uniform(2,3),
        color=color.hsv(0, 0, random.uniform(.9, 1))
        )

cube = Entity(model='cube',color=color.red,scale=3)

def update():
    cube.rotation_x = cube.rotation_x + 15
    cube.rotation_y = cube.rotation_y + 5


# Enemy()

sun = DirectionalLight()
sun.look_at(Vec3(1,-1,-1))
Sky()

app.run()

有人可以帮帮我吗???

要构建它,您需要打开终端并输入:

$ python -m ursina.build

当你这样做时,这将创建一个名为“build”的文件夹,打开它并打开“PROJECNAME.BAT”文件以开始游戏! 来自DiamondsBattle的回答,感谢大家!