我正在尝试使用 vscode 调试 python 脚本远程WSL https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl使用 Python 3.9.1 进行扩展。
当我启动调试模式(F5)时,立即显示以下消息:
找不到调试类型“python”的调试适配器描述符(扩展可能无法激活)
该消息向我提供了打开launch.json,我仍然不知道我必须在 json 文件中更改什么,以下是我当前的设置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "c:/<my_user_name>/projects",
},
}
]
}
到目前为止我已经尝试过的:
- 重新安装Python https://marketplace.visualstudio.com/items?itemName=ms-python.python扩展并阅读doc https://code.visualstudio.com/docs/remote/wsl-tutorial。然而,该文档根本无助于解决问题。这些步骤已在另一篇文章中建议here https://stackoverflow.com/questions/49607174/how-to-configure-vscode-to-debug-python-using-wsl大约3年前。
- 重新加载 vscode 以重新加载扩展,因为错误显示扩展可能无法激活。没有成功。
如果您在配置 WSL 之前已经安装了 VSCode,则可能会遇到此问题。我是这样解决的:
-
To the bottom left corner of VSCode, you may find the environment choice. Natively, this corresponds to windows, you might have to switch this to Remote-WSL: New Window
which will open VSCode in a new window.
-
在 VSCode 的调试选项卡中,您无需编辑任何配置,除非您需要定义解释器的位置。就我而言,我将位置定义为虚拟环境的 bin/ 目录。
祝你好运!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)