pythonursina

I have problem with ursina when it get compiled to exe


I started creating a shooter game with ursina, and I tried to get exe from this using pyinstaller. After I got the exe, when I run the app, it show me an error (o I have coded a new game with ursina, but I got this:

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.

my code:

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()

Solution

  • To build it, you need to open the terminal and type:

    $ python -m ursina.build
    

    And when you do, this will create a folder called "build", open it and open the "PROJECNAME.BAT" file to start the game!