4

I have just installed pyvisa on my mac with

$ pip install pyvisa

But when I was to test it using IDLE like this:

import visa
rm = visa.ResourceManager()

I got this:

    Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    rm = visa.ResourceManager()
  File "/Users/siyuqi/Library/Python/2.7/lib/python/site-packages/pyvisa/highlevel.py", line 1488, in __new__
    visa_library = open_visa_library(visa_library)
  File "/Users/siyuqi/Library/Python/2.7/lib/python/site-packages/pyvisa/highlevel.py", line 1460, in open_visa_library
    return cls(argument)
  File "/Users/siyuqi/Library/Python/2.7/lib/python/site-packages/pyvisa/highlevel.py", line 96, in __new__
    raise OSError('Could not open VISA library:\n' + '\n'.join(errs))
OSError: Could not open VISA library:

If I try 'pip install' in Terminal again, I will get the following result:

Requirement already satisfied (use --upgrade to upgrade): pyvisa in ./Library/Python/2.7/lib/python/site-packages
Requirement already satisfied (use --upgrade to upgrade): enum34 in ./Library/Python/2.7/lib/python/site-packages (from pyvisa)

Could anybody please kindly help me solve my problem? Thanks!

11
  • From what it looks like, the python library is installed - but I can't tell if it's trying to look for some separate dependency on your computer or something like that.
    – Zizouz212
    Commented Feb 22, 2016 at 1:39
  • some module only targetted for python3. try with python3
    – YOU
    Commented Feb 22, 2016 at 1:42
  • and looks like PyVISA is a wrapper to underlying library, you probably dont have that library installed or it does not works on OSX.
    – YOU
    Commented Feb 22, 2016 at 1:47
  • I'm on OSX and I tried on Python 2, 3.4 and 3.5 and I got the same error.
    – idjaw
    Commented Feb 22, 2016 at 1:47
  • Thank YOU. The official website of Pyvisa says it runs on Python 2.6+ and 3.2+. Does it mean I have to use Python 2.6.x or 3.2.x (instead of 2.7.x)?
    – Siyu Qi
    Commented Feb 22, 2016 at 1:48

1 Answer 1

7

The OSError occurs because PyVISA could not find the VISA library in your system. From the PyVISA documentation itself it says:

OSError: Could not open VISA library

This error occurs when you have not provided a path for the VISA library and PyVISA is not able to find it for you.

This could mean that the VISA library is not installed in your system or the VISA library is installed but in a directory that PyVISA does not know about.

You have to first install NI-VISA for PyVisa to work. PyVisa is only a Python binding for NI-VISA.

Here is a link to download and install NI-VISA to your system.


If it still outputs OSError: Could not open VISA library, the PyVISA documentation suggests that you do something like this.

visalib = VisaLibrary('/path/to/library')

or

rm = ResourceManager('Path to library')

You can also resort to creating a configuration file as described in Configuring the NI backend.

Source: http://pyvisa.readthedocs.org/en/stable/faq.html

2
  • I followed those instructions and got exactly the same error. The instructions say I'm supposed to point to "libvisa.so.7" on my windows machine. Maybe they meant to say .exe? Regardless, there is no libvisa.* installed by those instructions.
    – Seth
    Commented Nov 16, 2016 at 19:08
  • Found it! rm = visa.ResourceManager("C:/Windows/System32/visa32.dll")
    – Seth
    Commented Nov 16, 2016 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.