简体   繁体   English

VScode,你调试配置中的Python路径无效

[英]VScode,The Python path in your debug configuration is invalid

在此处输入图像描述

I keep getting this error.我不断收到此错误。 Other have faced this issue and have asked this question already and I have tried every single solution that was posted but I still get the error.其他人已经面临这个问题并且已经问过这个问题,我已经尝试了每个发布的解决方案,但我仍然得到错误。 Things I have tried to solve this problem:我试图解决这个问题的事情:

  • Uninstalled and reinstalled python and VScode.卸载并重新安装 python 和 VScode。
  • ctrl+shift+p and added python interpreter to path. ctrl+shift+p 并将 python 解释器添加到路径。
  • manually entered path in launch.json.在 launch.json 中手动输入路径。 "python": "C:\Users\saura\AppData\Local\Programs\Python\Python310\python.exe" "python": "C:\Users\saura\AppData\Local\Programs\Python\Python310\python.exe"

Not sure what more can I do.不知道我还能做什么。 I messed around with conda, julia, anaconda without having much knowledge about it and I have a feeling that might be the issue.我在没有太多了解的情况下与 conda、julia、anaconda 混在一起,我觉得这可能是问题所在。 I did however uninstalled everything regarding conda, julia, anaconda.然而,我确实卸载了有关 conda、julia、anaconda 的所有内容。 If anyone has any idea what could I do, I would really appreciate it.如果有人知道我能做什么,我将不胜感激。

Post the content of your launch.json file so that people can take a look at it.发布您的launch.json文件的内容,以便人们可以查看它。

You Configuration Should Look Like This:您的配置应如下所示:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Base",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "args": [],
            "python": "path-to-python"
        }
    ]
}

From menu bar of VS Code (Run), go to Open Configurations and paste above content after replacing path-to-python with yours.从 VS Code (Run) 的菜单栏中,转到Open Configurations并在将path-to-python替换为您的之后粘贴上面的内容。

Make sure you are using edited debug configuration when launching the debug for script.确保在启动脚本调试时使用已编辑的调试配置。

Look in the lower right corner of your interface, where you are prompted to choose a python interpreter .查看界面的右下角,系统会提示您选择python 解释器

在此处输入图像描述

You should just click there or use Ctrl + Shift + P to open the command palette and choose Python:Select Interpreter , then choose the appropriate python interpreter.您只需单击那里或使用Ctrl + Shift + P打开命令面板并选择Python:Select Interpreter ,然后选择适当的 Python 解释器。

I know you have tried many ways for this.我知道你为此尝试了很多方法。 But here's the problem, you haven't selected a python interpreter for vscode.但是问题来了,你还没有为 vscode 选择 python 解释器。 If none of the methods work, try reinstalling the python extension .如果这些方法都不起作用,请尝试重新安装python 扩展

Also, if the "python" configuration in your launch.json is the same as you showed in your question.此外,如果您的launch.json中的"python"配置与您在问题中显示的相同。 then it is wrong, you should use / or \\ .那么这是错误的,你应该使用/\\ like this:像这样:

// Example 1
"python": "C:/Users/saura/AppData/Local/Programs/Python/Python310/python.exe"

// Example 2
"python": "C:\\Users\\saura\\AppData\\Local\Programs\\Python\\Python310\\python.exe"

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

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