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

Visual Studio Code中Python调试异常:变量窗口无内容

Troubleshooting VS Code Python Debugger Not Showing Variables

Hey there! Let's work through why your VS Code debugger isn't displaying variables when running your Python 3.6.4 scripts. I've dealt with similar quirks before, so here are some practical fixes to try:

  • Double-check your selected Python interpreter
    Open the command palette (press Ctrl+Shift+P on Windows/Linux, Cmd+Shift+P on Mac), search for Python: Select Interpreter, and confirm you've picked your exact Python 3.6.4 installation. VS Code sometimes auto-selects a different environment or version, which breaks the debugger's ability to track variables.

  • Verify your launch configuration
    Open the .vscode/launch.json file (if you don't have one, click "create a launch.json file" in the debug panel and select Python). Your "Python: Current File" config should look like this:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "justMyCode": true
            }
        ]
    }
    

    Ensure program is set to ${file} (so it targets your open script) and justMyCode is enabled (this focuses on your variables instead of library code).

  • Make sure you've set a breakpoint
    Without a breakpoint, your script will run straight to completion before the debugger can load and display variables. Click the blank space left of a line number in your code to add a red breakpoint dot—try placing it right after you define some variables, then start debugging again.

  • Update VS Code and the Python extension
    Your VS Code version (1.23.1) is pretty outdated, and older versions often have compatibility bugs with Python interpreters. Upgrade VS Code to the latest release, then head to the extensions panel and update the Microsoft Python extension (the one with the blue logo). This alone fixes most old debugger issues.

  • Test with a minimal script
    Create a super simple test script to rule out issues with your original code:

    test_var = 42
    greeting = "Hello, debugger!"
    print(test_var, greeting)
    

    Add a breakpoint on the print line, start debugging, and check if test_var and greeting show up in the variables panel. If they do, your original script might have variables that aren't being executed (e.g., inside an unreachable if block) or optimized away.

  • Check the variables panel visibility
    Sometimes the variables panel gets accidentally hidden or collapsed. In the debug sidebar (left side of VS Code when debugging is active), make sure the "Variables" tab is selected and expanded—you should see your local and global variables listed there once the breakpoint hits.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 07:19:14