Has anyone had success running pyVisa on Snow Leopard with a NI GPIB module?
Based on all of the forums I have read on NI's website, it does not appear that the combination of NI VISA and pyVisa can be done on Max OS X.
The troubling part is that NI website has the NI VISA support listed for Mac OS X. However in their support pages, they do not list OS X as a supported OS.
Any comments or help would be greatly appreciated as I would really like to get away from having to use Windows to do this softw开发者_运维问答are development as well as allow cross platform support.
It turns out that NI-VISA 5.0 works well on 10.6.6.
The issue I was having was when calling pyVisa's visa.Instrument("GPIB::1") it said the library was not found. However when calling visa.get_instruments_list() displayed my GPIB adapter as GPIB0. Using this as the device I was able to connect properly.
There were a few changes that I had to make that were not documented well on NI's site (that I could find at least) in order to accomplish this. The most important being the name of the VISA library that NI-VISA 5.0 installs. It is found at /Library/Frameworks/Visa.framework/VISA
. I have not tried modifying the nsi file to automatically link to this library as the pyVisa documentation mentions.
I have been unable to install pyvisa with pip. I had to use easy_install. If anyone has had success installing pyvisa with pip, I would really like to know how!
System Settings:
Python 2.7 running virutalenv + virtualenvwrapper. Snow Leopard 10.6.6. NI-VISA 5.0
Sample Code:
from pyvisa.vpp43 import visa_library
visa_library.load_library("/Library/Frameworks/Visa.framework/VISA")
import visa
visa.get_instruments_list() # Yields: ['ASRL1', 'ASRL2', 'ASRL3', 'ASRL4', 'GPIB0::1']
temp = visa.Instrument("GPIB0::1")
print temp # Yeilds: Instrument("GPIB0::1::INSTR")
Update:
After moving to Lion I have found the same issues and have had to load the library manually each time. This makes me think I'm missing something.
I installed NI-VISA-5.0.0, NI-VISA-5.1.2 and PyVisa-1.4 on OSX 10.8.2 (Mountain Lion) and i get the following error
>>> import pyvisa.vpp43 as vpp43
>>>
>>>
>>> vpp43.visa_library.load_library('/Library/Frameworks/VISA.framework/VISA')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/vpp43.py", line 146, in load_library
self.__lib = self.__cdecl_lib = cdll.LoadLibrary(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
OSError: dlopen(/Library/Frameworks/VISA.framework/VISA, 6): no suitable image found. Did find:
/Library/Frameworks/VISA.framework/VISA: no matching architecture in universal wrapper
/Library/Frameworks/VISA.framework/VISA: no matching architecture in universal wrapper
>>>
Works fine in Mountain Lion 10.8.5.
- Install NI-VISA Runtime 5.4.
- Install pyvisa
First make an i386 binary of Python (mac os built-in) to force Python into 32-bit mode.
$ lipo -thin i386 -output python-i386 /usr/bin/python2.7
$ ./python-i386
And then:
# make sure pyvisa is available in the built-in python
import sys
sys.path.append('path-to-your-pyvisa')
from pyvisa.vpp43 import visa_library
visa_library.load_library("/Library/Frameworks/Visa.framework/VISA")
import visa
visa.get_instruments_list()
精彩评论