"Debug Adapter Executable not provide" in VS code for Python

Viewed 102

Try to debug the Python code in Container using VS Code Remote Container Extension.

After the docker build task, I got a "Debug Adapter Executable not provide" error. Where could be wrong?

enter image description here

launch.json

{
"configurations": [
    {
        "name": "Docker: Python - General",
        "type": "docker",
        "request": "launch",
        "preLaunchTask": "docker-run: debug",
        "python": {
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ],
            "projectType": "general"
        }
    }
]

}

tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "type": "docker-build",
        "label": "docker-build",
        "platform": "python",
        "dockerBuild": {
            "tag": "py:latest",
            "dockerfile": "${workspaceFolder}/Dockerfile",
            "context": "${workspaceFolder}",
            "pull": true
        }
    },
    {
        "type": "docker-run",
        "label": "docker-run: debug",
        "dependsOn": [
            "docker-build"
        ],
        "python": {
            "file": "app.py"
        }
    }
]

}

1 Answers

I also encountered this problem. After trying a fresh install of the VS Code Docker extension, to no avail, I noticed the actually command being triggered by the "docker-run: debug" task in the tasks.json:

docker run -dt -P --name "loadtiktokcampaigns-dev" --label 
"com.microsoft.created-by=visual-studio-code" -v 
"/Users/tnightengale/.vscode/extensions/ms-python.python-
2022.12.0/pythonFiles/lib/python/debugpy:/debugpy:ro,z" 
--entrypoint "python3" "loadtiktokcampaigns:latest"

The key here is the -v command that is attempting to mount the /debugpy files into the container from the VS Code Python extension files.

For some reason, those files were not actually located at that path on my Mac. Deleting the ms-python.python-2022.12.0/ folder and reinstalling the VS Code Python extension solved the issue for me.

Related