2

我最近安装了 Ursina 游戏引擎,我开始使用它,但是当我编写一个基本程序时,它给了我一个与 ursina 中的一些内置程序相矛盾的回溯,并以 Filenotfound Winerror 3 指向一个没有任何内容的音乐文件夹结束与python有关,我仔细检查了Ursina是否安装正确,但事实并非如此,我检查了它指向的文件夹,正如预期的那样,它只包含音乐。引擎的路径有问题吗?我希望你能回答我。无论如何这里是代码:

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

错误信息:

> 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'
4

1 回答 1

1

由于您将脚本直接放在桌面上,因此您将其设为项目文件夹。因此,当您尝试加载模型时,ursina 将搜索您桌面上的所有文件和文件夹以查找与该名称匹配的文件。

将您的脚本和相关资产移动到单独的文件夹中。

于 2022-01-04T17:12:59.417 回答