英文:
VS Code Python, entry in Run&Debug not present in launch.json
问题
I just started using VS Code to develop in Python, I have the official Python extension installed, and I'm trying to configure the Run & Debug menu.
In one of my workspaces, I created the following launch.json file, with THREE configurations (test.py, preview.py, and Project Tests):
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "test.py",
            "type": "python",
            "request": "launch",
            "program": "./test.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        },
        {
            "name": "preview.py",
            "type": "python",
            "request": "launch",
            "program": "./preview.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        },
        {
            "name": "Project Tests",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "cwd": "some_folder",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        }
    ]
}
However, in the Run & Debug menu, I see FOUR entries..."test.py", "preview.py", and "Project Tests", the ones I configured in launch.json, and "Python: File", which is applied to the currently open file in the IDE.
I was assuming this "Python: File" might be some default option which is always present, but then I have another workspace where I created launch.json with only one entry (process.py):
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "process.py",
            "type": "python",
            "request": "launch",
            "program": "./process.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        }   
    ]
}
And here I only have the corresponding entry in the menu as well.
I tried deleting and recreating the launch.json file in the first workspace, but the result is always the same. How does this work precisely?
英文:
I just started using VS Code to develop in Python, I have the official Python extension installed, and I'm trying to configure the Run&Debug menu.
In one of my workspaces, I created the following launch.json file, with THREE configurations (test.py, preview.py and Project Tests):
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "test.py",
            "type": "python",
            "request": "launch",
            "program": "./test.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        },
        {
            "name": "preview.py",
            "type": "python",
            "request": "launch",
            "program": "./preview.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        },
        {
            "name": "Project Tests",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "cwd": "some_folder",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        }
    ]
}
However, in the Run&Debug menu I see FOUR entries..."test.py", "preview.py" and "Project Tests", the ones I configured in launch.json, and "Python: File", which is applied to the currently open file in the IDE.
I was assuming this "Python: File" might be some default option which is always present, but then I have another workspace where I created launch.json with only one entry (process.py):
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "process.py",
            "type": "python",
            "request": "launch",
            "program": "./process.py",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "variablePresentation": {
                "all": "inline",
                "class": "group",
                "function": "hide",
                "special": "hide"
            }
        },
        
    ]
}
and here I only have the corresponding entry in the menu as well:
I tried deleting and recreating the launch.json file in the first workspace, but the result is always the same.
How does this work precisely?
答案1
得分: 1
Simply copying your launch.json does not lead to the same problem.
So I don't think this is only a problem with the launch or debug itself. I have a speculation that you can try it out:
Click Python and choose Python File then click on the gear.
This will add Python: File related settings in launch.json for you, and then try to manually delete them after saving launch.json.
英文:
Simply copying your launch.json does not lead to the same problem.
So I don't think this is only a problem with the launch or debug itself. I have a speculation that you can try it out:
Click Python and choose Python File then click on the gear.
This will add Python: File related settings in launch.json for you, and then try to manually delete them after saving launch.json.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。





评论