Exception pyvisa.errors.VisaIOError: VisaIOError(u'VI_ERROR_INV_OBJECT (-1073807346))
See original GitHub issueToday I updated to the latest Pyvisa 1.5.dev3, however, I got this exception every time the script is finished, by finished, I mean the following exception occurs only once no matter how many commands were sent to the instrument, which means, the exception is not thrown inside the write or read methods, but probably when the script is about to quit. for example, I asked “*IDN?” twice and quit, as a result I got the identities of the instrument twice and an exception at the end. Did anyone know the solution?
Rohde&Schwarz,FSV-3,1307.9002K03/101699,2.10
Rohde&Schwarz,FSV-3,1307.9002K03/101699,2.10
Exception pyvisa.errors.VisaIOError: VisaIOError(u'VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.',) in ignored
Hit any key to close this window...
Here’s the debug info:
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: Intel64 Family 6 Model 37 Stepping 5, GenuineIntel
Python:
Implementation: CPython
Executable: c:\python27\python.exe
Version: 2.7.6
Compiler: MSC v.1500 32 bit (Intel)
Bits: 32bit
Build: Nov 10 2013 19:24:18 (#default)
Unicode: UCS2
VISA:
#1: C:\Windows\system32\visa32.dll
found by: auto
32bit: True
64bit: False
Issue Analytics
- State:
- Created 9 years ago
- Comments:33 (17 by maintainers)
Top Results From Across the Web
PyVisa.errors.VisaIOError exception handling in Python
If all you import is visa , you can catch these exceptions with except visa.VisaIOError . Example: import visa try: # Things that...
Read more >Given Session or Object Reference Invalid in NI VISA - Support
When I attempt to open a new VISA session to my instrument or use an existing session, I receive Error – 1073807346 VISA:...
Read more >Python - Error VI_ERROR_INV_OBJECT while trying examples
pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.
Read more >How to use the pyvisa.errors.VisaIOError function in ... - Snyk
VisaIOError function in PyVISA. To help you get started, we've selected a few PyVISA examples, based on popular ways it is used in...
Read more >PyVISA error, version support - Google Groups
pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid. Am i doing something wrong or is it ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since I’m not the only one experiencing this I’m posting a bare bone version of my solution to the issue:
The trouble I have with atexit is that it delays the cleanup of the ResourceManager to the interpreter shutdown if used naively which is fine for a single script but more of a concern for long running applications, which is why using it for resources is not an option. Honestly not closing your resource before the end of a script is just bad practice (resources can be used as context managers to avoid that kind of problem) and in larger program it is also easy to avoid. All that said we could try to do something with an atexit handler using only a weakref so that it does not keep the ResourceManager alive for no reason. I am not sure that would fix the issue because we may still have some weird interaction between atexit and the gc but it may be worth trying.