【问题标题】:Visual Studio Code Python Debugger WindowsVisual Studio Code Python 调试器 Windows
【发布时间】:2018-04-12 21:29:47
【问题描述】:

我似乎遗漏了一些简单的东西,但我无法弄清楚为什么我无法在 Windows 上使用 Visual Studio Code 调试 python。我已经尝试按照Microsoftyoutube video 所示设置调试器。我已经完成了 Visual Studio Code(包括 python 扩展)和 Python 3.6 的全新安装。我没有安装其他 python 版本。我在 Python 调试器中不断收到以下错误:

cd "c:\Users\xxx\Documents\Python Scripts" ; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\python.exe" "C:\Users\xxx\.vscode\extensions\ms-python.python-2018.3.1\pythonFiles\PythonTools\visualstudio_py_launcher.py" "c:\Users\xxx\Documents\Python Scripts" 53746 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput "c:\Users\xxx\Documents\Python Scripts\.vscode\launch.json"
    -bash: cd: c:\Users\xxx\Documents\Python Scripts: No such file or directory
    env: ‘C:\\Users\\xxx\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe’: No such file or directory

它抱怨找不到python.exe文件,但显然可以,因为VS代码表明它已附加:

我的launch.json文件是默认的,所有的配置我都试过了:

    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}"
        },
        {
            "name": "Python: Attach",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "${workspaceFolder}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
        },
        {
            "name": "Python: Terminal (integrated)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Terminal (external)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "debugOptions": [
                "RedirectOutput",
                "Django"
            ]
        },
        {
            "name": "Python: Flask (0.11.x or later)",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "${workspaceFolder}/app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "module.name"
        },
        {
            "name": "Python: Pyramid",
            "type": "python",
            "request": "launch",
            "args": [
                "${workspaceFolder}/development.ini"
            ],
            "debugOptions": [
                "RedirectOutput",
                "Pyramid"
            ]
        },
        {
            "name": "Python: Watson",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/console.py",
            "args": [
                "dev",
                "runserver",
                "--noreload=True"
            ]
        },
        {
            "name": "Python: All debug Options",
            "type": "python",
            "request": "launch",
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "module": "module.name",
            "env": {
                "VAR1": "1",
                "VAR2": "2"
            },
            "envFile": "${workspaceFolder}/.env",
            "args": [
                "arg1",
                "arg2"
            ],
            "debugOptions": [
                "RedirectOutput"
            ]
        }
    ]
}

Pylinting 工作正常,我在 Visual Studio Code 中没有与 python 相关的自定义用户设置。我已经尝试在 settings.json 中将完整的文件路径设置为 python.exe,但没有任何区别。

非常感谢任何帮助。提前致谢

【问题讨论】:

    标签: windows python-3.x debugging visual-studio-code


    【解决方案1】:

    我遇到了同样的问题,但在对我的设置进行了几次调整后终于解决了。 确保所有其他设置都已到位,尤其是在 settings.json 中提到的 pythonPath ,并从 VS 代码的“扩展”工具栏中安装“python”。 只需将调试配置从 "Python: Scripts"(或您之前选择的任何其他配置)更改为 "Python: Terminal(external)" 即可去吧!

    【讨论】:

    • 对我的设置做了这么小的改动,但它终于奏效了,谢谢!
    【解决方案2】:

    我知道,这是一种痛苦,我正在经历同样的事情。

    显然python.exe 正在正确执行。您将继续看到该横幅,因为“这是引导调试器所必需的”。

    至少微软says是这样的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-03
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      • 2019-02-26
      相关资源
      最近更新 更多