简体   繁体   中英

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. 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. The error could be in libraries I am importing: selenium, pyvisa/visa, or 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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