简体   繁体   English

有没有办法在没有文件名的Python中找到错误的来源?

[英]Is there a way to find the source of an error in Python with no file name?

I've been getting several mystery errors after my program completes and exits successfully. 我的程序完成并成功退出后,我遇到了一些神秘的错误。 There were 3, but I fixed the "Nonetype" error by making a second import of an Agilent library local instead of global, I assume it was freeing the same object twice. 共有3个,但是我通过将安捷伦库的第二次导入而不是全局导入来解决了“ Nonetype”错误,我假设它两次释放了同一对象。 But I still get these two: 但是我仍然得到以下两个:

Exception ctypes.ArgumentError?: "argument 2: <type 'exceptions.TypeError?'>: wrong type" in ignored
Exception ctypes.ArgumentError?: "argument 2: <type 'exceptions.TypeError?'>: wrong type" in ignored

I'm not using ctypes. 我没有使用ctypes。 The error could be in libraries I am importing: selenium, pyvisa/visa, or labjack/labjackpython. 错误可能出在我要导入的库中:硒,pyvisa / visa或labjack / labjackpython。 I tried importing some of those libraries locally but that didn't seem to change anything. 我尝试在本地导入其中的某些库,但似乎没有任何改变。

Is there a way to hunt down the source of errors like this? 有没有办法找到这样的错误源? A file name and line number would be great. 文件名和行号会很好。 Thanks 谢谢

You can start your script with a python debugger or use a tool like GDB or strace to run your python program. 您可以使用python调试器启动脚本,也可以使用GDB或strace之类的工具运行python程序。

The python debuggers may fail to dig into imported compiled libraries, but with the other two you can get a stack trace which should show the library that causes the exception. python调试器可能无法挖掘导入的已编译库,但使用其他两个调试器,您可以获得堆栈跟踪,该跟踪应显示导致异常的库。

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

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