我正在嵌入式Linux板上调试python守护程序。我ssh到我运行程序的板子并输入调试器。鉴于这是一个守护进程,我正在使用celery中的rdb#Installonthesystempip3installcelery#Setinthecodefromcelery.contribimportrdbrdb.set_trace()#Connecttothedebuggertelnetlocalhost5899但是在该session中,tab键不会像通常在pdb中那样导致自动完成,并且up键不会滚动通过历史但打印^[[A.这些问题与缺少的readlinepython模块有关,但是在这种特殊情
假设我正在调试以下脚本:importipdbdefslow_function(something):#I'maveryslowfunctionreturnsomething_elsedeffast_function(something_else):#There'sabugherereturnfinal_outputsomething=1something_else=slow_function(something)ipdb.set_trace()final_output=fast_function(something_else)ipdb.set_trace()当遇到ipdb.set_tr
我是ipython的新手,我正在尝试使用ipython来调试我的代码。我做了:[1]:%pdbAutomaticpdbcallinghasbeenturnedON然后In[2]:%runmycode.py在代码中,我有1/0,所以它会引发异常并自动进入调试session。ZeroDivisionError:floatdivisionipdb>variablearray([0.00704313,-1.34700666,-2.81474391])所以我可以访问变量。但是当我执行以下操作时:ipdb>b=variable***Thespecifiedobject'=variable'isno
来自Python文档:sys.excepthook(type,value,traceback)Thisfunctionprintsoutagiventracebackandexceptiontosys.stderr.Whenanexceptionisraisedanduncaught,theinterpretercallssys.excepthookwiththreearguments,theexceptionclass,exceptioninstance,andatracebackobject.Inaninteractivesessionthishappensjustbeforeco
试图找到如何执行ipdb(或pdb)命令,例如disable。在disable上调用h命令表示disablebpnumber[bpnumber...]Disablesthebreakpointsgivenasaspaceseparatedlistofbpnumbers.那么我该如何获得这些bp数字呢?正在查看命令列表,无法显示bp编号[编辑]break、b和infobreakpoints命令不执行任何操作,尽管在我的模块中我显然设置了1个断点,如下所示进口PDB;pdb.set_trace()-与ipdb相同。此外,info未定义。pdb中help的输出:Documentedcomma
如何让python调试器pdb在退出时中断?另外,我为什么要这样做,我怎样才能打破引发的异常? 最佳答案 覆盖函数:old_sys_exit=sys.exitdefnew_sys_exit(value):print"insysexit%s"%valueold_sys_exit(value)sys.exit=new_sys_exit然后设置断点:(Pdb)bnew_sys_exit它有效,也适用于调用sys的其他模块。 关于python-PDB如何在退出时中断?,我们在StackOverf
我正在调试一个sys.path看起来像的python脚本sys.path=['','home/my_library',..]在使用pdb时,我无法在my_library的模块中设置断点。该脚本使用以下内容导入库:importmy_libraryasfoo反过来,my_library通过以下方式提供其模块:frommy_moduleimportbar如何在我的脚本上运行pdb时处理my_module的代码?PS:我试过以下方法都没有成功:bmy_module:1bmy_library.my_module:1bmy_library.bar:1bfoo.my_module:1bfoo.bar
我发现自己经常在pdb中这样做:importpprintpprint.PrettyPrinter().pprint(variable_of_interest)是否有更好的方法从pdb中漂亮地打印变量?我正在寻找更容易输入的东西,理想情况下是pdb中始终可用的东西,这样我可以在调试时随时使用它。 最佳答案 在pdb文档的DebuggerCommands部分:ppexpressionLikethepcommand,exceptthevalueoftheexpressionispretty-printedusingthepprintmod
在调试我的Django应用程序时,我使用pdb与pdb.set_trace()进行交互式调试。但是,当我修改文件时,本地django网络服务器会重新启动,然后我无法看到我在终端中输入的内容,直到我输入reset。无论如何,这是否会自动发生?这真的很烦人,必须取消运行服务器并一直重置和重新启动它。有人告诉我它不会发生在其他操作系统(ubuntu)上,所以有没有办法让它不会发生在Mac上?(我正在使用SnowLeopard)。 最佳答案 好的-这对我有用我创建了一个~/.pdbrc并添加了importosos.system("sttys
我正在尝试使用pdb来调试Flask应用程序。设置断点很容易;我只是使用bindex在调用index()时中断,或者使用b44在第44行设置断点。断点适用于b44,这是main的开始,但bindex不起作用。在命令行中打印“Indexiscalled”表示调用了该方法,但并没有在pdb中停止。@app.route('/',methods=['GET','POST'])defindex():print"Indexiscalled"name=None...returnrender_template('index.html',form=form,name=name)if__name__=='