Iam trying to remote dubug python in VSC:
It is main.py file:
print('Hello, World')
debug.py:
import ptvsd
ptvsd.enable_attach('my_secret', address=('0.0.0.0', 7102))
ptvsd.wait_for_attach()
Dockerfile:
FROM python:3.6-slim
EXPOSE 7102
RUN pip install ptvsd
WORKDIR /app
COPY . .
CMD ["python", "debug.py"]
and it is launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach (Remote Debug)",
"type": "python",
"request": "attach",
"localRoot": "${workspaceRoot}",
"remoteRoot": "/app",
"port": 7102,
"secret": "my_secret",
"host": "172.17.0.3"
}
]
}
It is a command to build and start container:
docker build -t python-for-debug .
docker run -it -p 7102:7102 python-for-debug
When I run the debugger I get:
screen of vs code
No any errors at debug console, not output, not problems. No any output for running container. No docker logs
VS Code version: 1.15.0
Docker version 17.06.0-ce, build 02c1d87
解决方案
Hi you should use ptvsd 3, so change the RUN line in Dockerfile to:
RUN pip3 install ptvsd==3.0.0
also run locally ptvsd installation:
$pip3 install ptvsd==3.0.0