skip to Main Content

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"
        }
    }
]

}

2

Answers


  1. 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.

    Login or Signup to reply.
  2. Looks like it is resolved if you define a local python interpreter even if you want to use docker. Open a .py file and define it with the button right bottom.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search