简体   繁体   English

从外部脚本使用 vscode 调试 python

[英]Debug python with vscode from an external script

How can I debug a python program from an external app?如何从外部应用程序调试 python 程序?
I'm using guildAI which is an external utility, that when running guild run train.py internally it runs python train.py but with other wrappers.我正在使用guildAI ,它是一个外部实用程序,在内部运行guild run train.py它运行python train.py但使用其他包装器。
Is there a way, to somehow debug (like remote debugging) with vs code such applications?有没有办法用 vs 代码这样的应用程序以某种方式调试(如远程调试)?
Ie tell vs code to run guild run train.py for me?即告诉vs代码为我运行guild run train.py or some other way或其他方式

You want to do what's called " local attach ".您想做所谓的“ 本地附加”。 Basically what you need to do is install ptvsd with your app, call ptvsd.enable_attach() and ptvsd.wait_for_attach() , and then use breakpoint() to cause the debugger to pause upon attach to let you start walking through your app.基本上你需要做的是在你的应用程序中安装 ptvsd,调用ptvsd.enable_attach()ptvsd.wait_for_attach() ,然后使用breakpoint()使调试器在附加时暂停,让你开始浏览你的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM