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

前端 未结 3 1099
悲&欢浪女
悲&欢浪女 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:41

    I think the problem is that your docker process terminates.

    You start your debug.py as a command in the Dockerfile. So Docker starts the task, waits for your debugger to attach and then exits because there is nothing more to do.

    Seems you need to place your code into debug.py as the easiest try. And please remember that you cannot place the breakpoint right after

    ptvsd.wait_for_attach()
    

    so you'd better write some spare lines between.
    Hope this helps.

提交回复
热议问题