Visual Studio Code - how to remote debug python code in a Docker Container

前端 未结 3 1106
悲&欢浪女
悲&欢浪女 2020-12-10 04:29

Iam trying to remote dubug python in VSC:

It is main.py file:

print(\'Hello, World\')

debug.py:

import ptvsd
ptvsd.         


        
3条回答
  •  一个人的身影
    2020-12-10 04:46

    Edit 12-AUG

    I setup a test version to see what could be wrong. The issue is that the Visual Studio Code makes not connections to the debugger it failed before connecting only

    See the exception is in their JS code.

    There is a open issue as well on github

    https://github.com/DonJayamanne/pythonVSCode/issues/805

    Your best bet is to either add these details to the issue or open a new one

    Original Answer:

    The behavior you are seeing is actually correct. I saw your screenshot and you had print "Hello World" in your client script and below code is your in remote

    import ptvsd
    ptvsd.enable_attach('my_secret', address=('0.0.0.0', 7102))
    ptvsd.wait_for_attach()
    

    If you see the below url

    https://donjayamanne.github.io/pythonVSCodeDocs/docs/debugging_remote-debugging/

    Read the below quote

    Make the above change in both script files (i.e. scripts on both the local and remote machines) However on the client side, ensure the above two lines are commented out I.e. this is necessary to ensure we have the same line numbers on the server and they match.

    The execution of code debugging all happens inside your container. While your code in local machine is more to be able to visualize which the line the code inside the container is

提交回复
热议问题