如何使用 Eclipse 和 Pydev 正确调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/864750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I debug properly using Eclipse and Pydev?
提问by prodev42
I have got Pydev configured properly so it runs my app, however when I want to inspect/trace my code by setting up breakpoints the debugger does not kick in (can't trace). Does anyone got any idea what's going on here?
我已经正确配置了 Pydev,因此它可以运行我的应用程序,但是当我想通过设置断点来检查/跟踪我的代码时,调试器不会启动(无法跟踪)。有谁知道这里发生了什么?
采纳答案by David Parmenter
--noreload
option is crucial, otherwise server will fork and your breakpoint won't trigger.
--noreload
选项至关重要,否则服务器将分叉并且您的断点不会触发。
回答by Ramin
Ordinarily you wouldn't have to select manage.py and hit debug. From your description it sounds like you may not have set up the Django launch params in the Run/Debug settings panel.
通常,您不必选择 manage.py 并点击调试。从您的描述来看,您可能没有在“运行/调试”设置面板中设置 Django 启动参数。
Here are some step by step instructions:
以下是一些分步说明:
http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html
http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html
and
和
http://developeradventures.blogspot.com/2008/03/eclipse-django-debugging.html
http://developeradventures.blogspot.com/2008/03/eclipse-django-debugging.html
The important part is adding the entry to the Run/Debug settings. When it's time to debug, set the breakpoint, on the Eclipse toolbar click on the Debug button's drop-down arrow and select the Django project you've defined. Then from a browser window go to your Django server's URL. Eclipse should stop at the breakpoint.
重要的部分是将条目添加到运行/调试设置中。当需要调试时,设置断点,在 Eclipse 工具栏上单击 Debug 按钮的下拉箭头并选择您定义的 Django 项目。然后从浏览器窗口转到您的 Django 服务器的 URL。Eclipse 应该在断点处停止。
回答by prodev42
Ok I think I found what my problem was. I had to set the breakpoint on the def statement in views.py instead of the statements after it.
好的,我想我找到了我的问题所在。我必须在 views.py 中的 def 语句上设置断点,而不是它后面的语句。
回答by Craig Trader
If you're debugging the Django runserver
, make certain you specify the --noreload
command line parameter. Otherwise the debugger ends up looking at the wrong python instance and never trips any breakpoints.
如果您正在调试 Django runserver
,请确保指定--noreload
命令行参数。否则调试器最终会查看错误的 python 实例,并且永远不会触发任何断点。