简体   繁体   English

在 vscode 中找不到 python 调试适配器 - WSL:Ubuntu

[英]python debug adapter not being found in vscode - WSL:Ubuntu

I'm trying to debug a python script in vscode using the Remote WSL extension with Python 3.9.1.我正在尝试使用带有 Python 3.9.1 的远程 WSL扩展在 vscode 中调试 python 脚本。

When I start debugging mode(F5), the below message is immediately shown:当我开始调试模式(F5)时,立即显示以下消息:

Couldn't find a debug adapter descriptor for debug type 'python' (extension might have failed to active)找不到调试类型“python”的调试适配器描述符(扩展可能无法激活)

The message offers me to Open launch.json , I still don't know what I have to change in my json file, below are my current settings:该消息让我打开 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",
            },
        }
    ]
}

What I have tried until now:我到目前为止所尝试的:

  • Re-installed Python extension and read the doc .重新安装Python扩展并阅读文档 However the doc does not help to solve the issue at all.但是,该文档根本无助于解决问题。 These steps has been already suggest in another post here almost 3 years ago.大约 3 年前, 这里的另一篇文章已经建议了这些步骤。
  • Reload vscode in order to reload the extensions, as the error shows an extensions might have failed to active.重新加载 vscode 以重新加载扩展,因为错误显示扩展可能无法激活。 No success.没有成功。

If you have VSCode, installed already before you could configure WSL, you could be facing this issue.如果您在配置 WSL 之前已经安装了 VSCode,则可能会遇到此问题。 Here's how I resolved it:这是我解决它的方法:

  1. To the bottom left corner of VSCode, you may find the environment choice.在 VSCode 的左下角,您可能会找到环境选项。 Natively, this corresponds to windows, you might have to switch this to Remote-WSL: New Window which will open VSCode in a new window.在本机上,这对应于 windows,您可能必须将其切换到Remote-WSL: New Window ,它将在新的 window 中打开 VSCode。 在此处输入图像描述

  2. In the debug tab of VSCode, you don't have to edit any configuration, except you need to define the location of your interpreter.在 VSCode 的调试选项卡中,您无需编辑任何配置,除非您需要定义解释器的位置。 In my case, I defined the location to be as my virtual environments' bin/ directory.就我而言,我将位置定义为我的虚拟环境的 bin/ 目录。

Good Luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM