如何使用Python中的spyder有效地进行调试? [英] How do I debug efficiently with spyder in Python?

查看:237
本文介绍了如何使用Python中的spyder有效地进行调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢Python,也喜欢Spyder,但是我发现使用Spyder进行调试很糟糕!

I like Python and I like Spyder but I find debugging with Spyder terrible!


  • 每次我设置断点时,我都需要按下两个按钮:首先是
    调试,然后是继续按钮(它会自动在第一行
    暂停),这很烦人。

  • 此外,与其使用具有自动完成功能的标准iPython控制台等,不如说我有一个糟糕的ipdb >>控制台,这只是垃圾。

  • 最糟糕的是,即使我编写打印稿或进行简单评估以找出错误所在,该控制台也会非常频繁地冻结。这比matlab差得多。

  • 最后但并非最不重要的一点是,如果我从
    ipdb >>控制台中调用一个函数,并在其中插入一个断点,它将不会就此停止。
    似乎我必须在开始
    调试(ctrl + F5)之前在其中放置断点。

  • Every time I put a break point, I need to press two buttons: first the debug and then the continue button (it pauses at first line automatically) which is annoying.
  • Moreover, rather than having the standard iPython console with auto completion etc I have a lousy ipdb>> console which is just garbage.
  • The worst thing is that this console freezes very frequently even if I write prints or simple evaluation to try to figure out what is the bug. This is much worse than matlab.
  • Last but not least, if I call a function from within the ipdb>> console, and put a breakpoint in it, it will not stop there. It seems like I have to put the breakpoint there before I start the debugging (ctrl+F5).

您有解决方案吗,或者您能告诉我如何调试python脚本和函数吗?

Do you have a solution or maybe can you tell me how you debug python scripts and functions?

我在Windows 8.1 64bit上使用全新安装的Anaconda。

I am using fresh install of Anaconda on a Windows 8.1 64bit.

推荐答案

Spyder dev here )我们知道Spyder的调试经验远非理想。我们现在提供的功能与标准Python调试器非常相似,但是我们正在努力改进下一个主要版本中的功能,以提供更接近任何科学家对调试器的期望的东西(总之,常规的IPython控制台可以您可以检查并绘制当前断点处的变量)。

(Spyder dev here) We're aware the debugging experience in Spyder is far from ideal. What we offer right now is very similar to the standard Python debugger, but we're working to improve things in our next major version to provide something closer to what any scientist would expect of a debugger (in short, a regular IPython console that lets you inspect and plot variables at the current breakpoint).

现在,有关您的点了:


  1. 是的。我们正在考虑进行改进,以便如果用户按下运行按钮,并且当前文件中存在断点,则Spyder进入调试模式并执行程序,直到遇到第一个断点为止。

  1. It's true. We're thinking to improve that so that if the user press the Run button, and there is a breakpoint present in the current file, then Spyder enters in debug mode and executes the program until the first breakpoint is met.

ipdb 是IPython调试器控制台。不幸的是,由于IPython体系结构的限制,它非常有限(没有代码完成,也没有带有箭头的历史记录)。此外,无法在 ipdb 或常规 pdb 控制台中运行任意Python代码。可以在 ipdb 中运行的命令是评估其中的 help 命令时可以阅读的命令。

ipdb is the IPython debugger console. Unfortunately, due to limitations in the IPython architecture, it's very limited (no code completion and no history browsing with arrows). Furthermore, it's not possible to run arbitrary Python code in either ipdb or a regular pdb console. The commands you can run in ipdb are the ones you can read when evaluate the help command inside it.

这是因为,正如我所说,您无法评估任意Python代码。

That's because, as I said, you can't evaluate arbitrary Python code.

您需要在我们的编辑器中放置新的断点,以便它们与我们的Python / IPython控制台同步

You need to put new breakpoints in our Editor so that they are synced with our Python/IPython consoles

这篇关于如何使用Python中的spyder有效地进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆