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

Blender 4.2通过VS Code启动开发服务器失败,debugpy安装报错

Blender 4.2升级后VS Code调试服务器启动失败(debugpy权限错误)

我使用VS Code搭配Blender开发插件和Python扩展进行开发,Blender 4.1版本下一切正常,但升级到4.2版本后,启动开发服务器时出现如下错误,无法安装debugpy:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib64/python3.12/shutil.py", line 847, in move
    os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/tmp/pip-target-zxossim0/lib/python/debugpy-1.8.5.dist-info' -> '/usr/lib64/python3.12/site-packages/debugpy-1.8.5.dist-info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gras/.local/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
    status = _inner_run()
             ^^^^^^^^^^^^
  File "/home/gras/.local/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
    return self.run(options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gras/.local/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gras/.local/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 519, in run
    self._handle_target_dir(
  File "/home/gras/.local/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 578, in _handle_target_dir
    shutil.move(os.path.join(lib_dir, item), target_item_dir)
  File "/usr/lib64/python3.12/shutil.py", line 863, in move
    copytree(src, real_dst, copy_function=copy_function,
  File "/usr/lib64/python3.12/shutil.py", line 600, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/shutil.py", line 498, in _copytree
    os.makedirs(dst, exist_ok=dirs_exist_ok)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/usr/lib64/python3.12/site-packages/debugpy-1.8.5.dist-info'

################################################################################
>   could not install debugpy
################################################################################

已尝试的操作:

  • 从官网下载debugpy 1.8.5 zip包,在conda环境手动安装
  • 在全局环境手动安装debugpy 1.8.5

请问我遗漏了哪些操作?


解决方案

1. 给Blender内置Python安装debugpy

Blender 4.2自带独立的Python环境,你之前安装到conda或全局Python的debugpy不会被Blender识别。需要直接针对Blender的Python进行安装:

  • 找到Blender 4.2的Python路径(Linux下通常为/usr/share/blender/4.2/python/bin/python3.12)
  • 执行命令:
/path/to/blender-python -m pip install debugpy==1.8.5 --user

--user参数会将包安装到当前用户目录,避免系统级权限问题。

2. 修正VS Code调试配置的Python路径

打开.vscode/launch.json,确保配置中的pythonPath指向Blender自带的Python,而非系统或conda环境的Python:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Blender Debug",
            "type": "python",
            "request": "launch",
            "program": "/path/to/blender",
            "args": ["--python", "${workspaceFolder}/your_addon.py"],
            "pythonPath": "/path/to/blender/4.2/python/bin/python3.12",
            "console": "integratedTerminal"
        }
    ]
}

3. 解决跨设备链接错误

错误中的Invalid cross-device link说明/tmp和/usr位于不同磁盘分区,导致pip无法直接移动文件。可以将pip临时目录指定到与目标目录同分区的位置:

# 先创建临时目录
mkdir -p /home/gras/tmp
# 设置临时目录环境变量后安装
export TMPDIR=/home/gras/tmp
/path/to/blender-python -m pip install debugpy==1.8.5 --user

4. 避免系统级Python安装

不要尝试给/usr/lib64/python3.12(系统Python)安装包,除非使用sudo,但这可能破坏系统环境。优先使用--user参数或Blender自带Python的用户目录进行安装。

内容的提问来源于stack exchange,提问作者Cristian Cutite

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 07:17:02