
【VSCode】如何用vscode调试blender代码
在玩blender时,网上的调试方法是通过这种方法,安装插件后进行调试。这篇文章针对比较老的版本。那时还是用的ptvsd。现在vscode的python debugger已经升级到。我们在玩的时候可以通过配置手动使用新的debugger。...
·
【VSCode】如何用vscode调试blender代码
如何用vscode调试blender python代码
在玩blender时,网上的调试方法是通过Blender python debugger这种方法,安装插件后进行调试。这篇文章针对比较老的vscode python
版本。那时还是用的ptvsd
。现在vscode的python debugger已经升级到debugpy。我们在玩的时候可以通过配置手动使用新的debugger。具体的操作如下:
在blender的python环境中安装debugpy
通过以下的脚本,查看blender python interpreter的位置
blender --background --python-expr "import sys; print(sys.exec_prefix)"
找到pyhton位置后要修改自己的PATH变量增加这个python的执行路径。安装pip和debugpy
python3 -m ensurepip && pip3 install debugpy
配置vscode
完事后在vscode中添加调试配置文件。
//launch.json
"version": "0.2.0",
"configurations": [
{
"name":"Python: Remote Attach",
"type":"python",
"request":"attach",
"connect":{"host":"localhost","port":5678},
"pathMappings":[{
"localRoot":"${workspaceFolder}",
"remoteRoot":"."}]},
}
...
在代码中加入如下内容:
import debugpy
debugpy.listen(5678)
debugpy.wait_for_client()
通过命令行启动需要调试的脚本
blender --background --python <script>
最后在vscode debug时选择“Python: Remote Attach”,就可以在vscode中断点调试了。
更多推荐
所有评论(0)