You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac终端运行Ursina代码无法加载.blend文件问题求助

Ursina框架加载.blend文件报错:找不到Blender安装路径(MacOS)

问题场景

运行基于Ursina框架的Python代码加载.blend格式3D模型时,终端抛出如下错误:

raise Exception('error: trying to load .blend file, but no blender installation was found. blender_paths:', application.blender_paths)
Exception: ('error: trying to load .blend file, but no blender installation was found. blender_paths:', {})

执行代码如下:

from ursina import *

app=Ursina()

e = Entity(model="huskyb", position = (0,0,0))

已在~/.zshrc中配置Blender路径:

export PATH="/Applications/Blender.app/Contents/MacOS/blender:$PATH"

替换为.obj格式模型时,代码可正常运行。


解决步骤

1. 验证环境变量是否生效

先在终端执行命令,确认Blender路径已加入系统PATH:

echo $PATH

检查输出中是否包含/Applications/Blender.app/Contents/MacOS/blender。如果没有,执行以下命令刷新配置:

source ~/.zshrc

之后重新运行Python代码。

2. 手动指定Blender路径给Ursina

若PATH配置生效但Ursina仍无法识别,可在代码中直接指定Blender路径,强制框架使用正确的程序:

from ursina import *

# 手动指定Blender执行文件路径
application.blender_paths['blender'] = '/Applications/Blender.app/Contents/MacOS/blender'

app = Ursina()
e = Entity(model="huskyb", position=(0,0,0))

app.run()

3. 检查版本兼容性

确保安装的Blender版本为2.8及以上,Ursina对低版本Blender的支持有限,版本不匹配可能导致路径检测失败。

4. 确认.blend文件路径

确保huskyb.blend文件位于Ursina默认模型目录(项目根目录的models文件夹,或与代码同目录),若文件在其他位置,需在model参数中填写完整路径,比如:

e = Entity(model="path/to/huskyb.blend", position=(0,0,0))

内容的提问来源于stack exchange,提问作者Prema S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 02:13:16