Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VsCode debug Python in docker can not spawn debugger #454

Closed
mhlg opened this issue Oct 30, 2020 · 3 comments
Closed

VsCode debug Python in docker can not spawn debugger #454

mhlg opened this issue Oct 30, 2020 · 3 comments

Comments

@mhlg
Copy link

mhlg commented Oct 30, 2020

I'm following the instructions as for https://code.visualstudio.com/docs/containers/debug-python

this used to work before upgrading docker to version 19.03.13

Python 3.7.6
Docker version 19.03.13, build 4484c46d9d

Create a project folder
mkdir my-project && cd my-project

Create a minimal python file named app.py
`
def main():
print('HELLO')

if name == "main":
main()
`

Create a python3 virtual environment.
python3 -m venv py-venv

setting.json
{ "python.pythonPath": "py-venv/bin/python" }

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

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

Create a Dockerfile
`
FROM python:3.8-slim-buster
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app
ADD . /app

RUN useradd appuser && chown -R appuser /app
USER appuser

CMD ["python", "app.py"]
`

Run Debug

and the following error occurs

Couldn't spawn debuggee: [Errno 2] No such file or directory: '/Users/.../py_docker_debug/py-venv/bin/python'

Command line:['/Users/.../py_docker_debug/py-venv/bin/python', '/debugpy', '--connect', 'host.docker.internal:52703', '--configure-qt', 'auto', '--adapter-access-token', '875b8dec0efaabdcdfad7028575706dbb916c2d8bde6e3fd8c25da2142db2a8a', 'app.py']

@int19h
Copy link
Contributor

int19h commented Nov 2, 2020

It looks like it'll require some changes on vscode-docker side to fix. I'll follow up in the original repo.

@mhlg
Copy link
Author

mhlg commented Nov 2, 2020

on vscode-docker side to fix. I'll follow up in the original repo.

Thanks @int19h

@bwateratmsft
Copy link

This will be a dupe of #463

@int19h int19h closed this as completed Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@int19h @mhlg @bwateratmsft and others