Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyvisa.errors.VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient ... when executing a script, but manually from interpreter works #375

Open
nexysm opened this issue Jun 1, 2023 · 3 comments

Comments

@nexysm
Copy link

nexysm commented Jun 1, 2023

I have a very strange issue. When trying to open a resource from the terminal interpreter it works, but it doesn't when the very same code is executed inside the script. Here is the script:

import pyvisa
import time

rm = pyvisa.ResourceManager()
time.sleep(2)
resources = rm.list_resources()
print (resources)
time.sleep(2)
print (resources)
instrument = rm.open_resource('TCPIP::192.168.188.148::INSTR')

The error is following:

/usr/local/lib/python3.7/dist-packages/pyvisa_py/tcpip.py:407: UserWarning: TCPIP:instr resource discovery is limited to the default interface.Install psutil: pip install psutil if you want to scan all interfaces.
  UserWarning,
('TCPIP::192.168.188.148::INSTR',)
('TCPIP::192.168.188.148::INSTR',)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/tcpip.py", line 452, in after_parsing
    self.interface = Vxi11CoreClient(host_address, port, self.open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/tcpip.py", line 356, in __init__
    rpc.TCPClient.__init__(self, host, prog, vers, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/protocols/rpc.py", line 821, in __init__
    pmap = TCPPortMapperClient(host, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/protocols/rpc.py", line 801, in __init__
    RawTCPClient.__init__(self, host, PMAP_PROG, PMAP_VERS, PMAP_PORT, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/protocols/rpc.py", line 452, in __init__
    self.connect(1e-3 * open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/protocols/rpc.py", line 486, in connect
    raise RPCError("can't connect to server")
pyvisa_py.protocols.rpc.RPCError: can't connect to server

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "short_test.py", line 10, in <module>
    instrument = rm.open_resource('TCPIP::192.168.188.148::INSTR')
  File "/usr/local/lib/python3.7/dist-packages/pyvisa/highlevel.py", line 3284, in open_resource
    res.open(access_mode, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa/resources/resource.py", line 279, in open
    self._resource_name, access_mode, open_timeout
  File "/usr/local/lib/python3.7/dist-packages/pyvisa/highlevel.py", line 3209, in open_bare_resource
    return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/highlevel.py", line 167, in open
    sess = cls(session, resource_name, parsed, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/tcpip.py", line 85, in __new__
    return newcls(resource_manager_session, resource_name, parsed, open_timeout)
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/sessions.py", line 324, in __init__
    self.after_parsing()
  File "/usr/local/lib/python3.7/dist-packages/pyvisa_py/tcpip.py", line 454, in after_parsing
    raise errors.VisaIOError(constants.VI_ERROR_RSRC_NFOUND)
pyvisa.errors.VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system.`
@MatthieuDartiailh
Copy link
Member

That's weird indeed. Does the same happen if you do not list the resources ?

@MatthieuDartiailh MatthieuDartiailh transferred this issue from pyvisa/pyvisa Jun 1, 2023
@MatthieuDartiailh
Copy link
Member

I transferred the issue since you use the pyvisa-py backend

@nexysm
Copy link
Author

nexysm commented Jun 1, 2023

That's weird indeed. Does the same happen if you do not list the resources ?

No, in that case it doesnt happen, and I also increased the delay after listing the resources and runs fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants