Skip to content

Visual Studio Code debugs python 2.7 app in a docker container with python3 #3585

Answered by LeiteMarga
LeiteMarga asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you so much for the feedback - really appreciate it! We managed to get it to work using ptvsd with the following configurations:

manage.py
from django.conf import settings

if settings.DEBUG:
    print(os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'))
    if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
        import ptvsd
        ptvsd.enable_attach(address = ('0.0.0.0', 3000))
        print "Attached remote debugger"

launch.json
{
"name": "Django",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"port": 3000,
"host": "localhost"
}

docker-compose.yml
ports:
- "8000:8000"
-…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@LeiteMarga
Comment options

@LeiteMarga
Comment options

@bwateratmsft
Comment options

@LeiteMarga
Comment options

@bwateratmsft
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bwateratmsft
Comment options

Answer selected by bwateratmsft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants