pythonursina

Why is my python program giving me a filenotfound WinError 3 every time I use the ursina engine?


I have installed the Ursina game engine recently and I am getting started with it, but as I write a basic program it gives me a traceback contradicting some built in programs in ursina and ending with a Filenotfound Winerror 3 pointing to a music folder which has nothing to do with python, I double checked if Ursina is installed properly but it was not the case, and I checked the folder it is pointing to which as expected contained only music. Is there a problem with the path of the engine? I hope you can answer me. Anyway here is the code:

from ursina import *           # this will import everything we need from ursina with just one line.

app = Ursina()

player = Entity(
    model = 'cube' ,           # finds a 3d model by name
    color = color.orange,
    scale_y = 2
    )

def update():                  # update gets automatically called by the engine.
    player.x += held_keys['d'] * .1
    player.x -= held_keys['a'] * .1


app.run()

The error message:

> package_folder: C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina
asset_folder: c:\Users\user\Desktop
screen resolution: (1920, 1080)
Traceback (most recent call last):
  File "c:\Users\user\Desktop\geme.py", line 1, in <module>
    from ursina import *           # this will import everything we need from ursina with just one line.
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\__init__.py", line 28, in <module>     
    from ursina.raycaster import raycast, boxcast
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\raycaster.py", line 14, in <module>    
    class Raycaster(Entity):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\raycaster.py", line 16, in Raycaster   
    _boxcast_box = Entity(model='cube', origin_z=-.5, collider='box', color=color.white33, enabled=False, eternal=True)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\entity.py", line 105, in __init__      
    setattr(self, key, kwargs[key])
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\entity.py", line 201, in __setattr__   
    m = load_model(value, application.asset_folder)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\ursina\mesh_importer.py", line 38, in load_model
    for filename in path.glob(f'**/{name}{filetype}'):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1166, in glob
    for p in selector.select_from(self):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 599, in _select_from
    for starting_point in self._iterate_directories(parent_path, is_dir, scandir):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 589, in _iterate_directories
    for p in self._iterate_directories(path, is_dir, scandir):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 589, in _iterate_directories
    for p in self._iterate_directories(path, is_dir, scandir):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 589, in _iterate_directories
    for p in self._iterate_directories(path, is_dir, scandir):
  [Previous line repeated 12 more times]
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 578, in _iterate_directories
    with scandir(parent_path) as scandir_it:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'c:\\Users\\user\\Desktop\\Education\\Music\\Plugins & wav\\unison midi pack\\Chord-Templates-s8nrci\\Chord Templates\\Blues Chord Templates Pack\\Major\\Ab_Major\\Substitute 
Chords\\Borrowed Chords\\Dominant\\Dominant7 b5 Chords\\Dominant7 b5 Chord Inversions\\A#7 b5 Inversions'

Solution

  • Since you put your script directly on the Desktop, you made that your project folder. So when you try to load a model, ursina will search all your files and folders on the desktop for a file matching that name.

    Move your scripts and relevant assets into a separate folder.