5

I'm on Mac OS X v10.8.5 (Mountain Lion). I've installed NI-VISA 5.4 and PyVisa 1.5. When I try 'import visa', I get this traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named visa

Printing the sys.path shows this in the listing:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.5.dev0.dev-py2.7.egg

I have also tried this:

import pyvisa
from pyvisa.vpp43 import visa_library
visa_library.load_library("/Library/Frameworks/VISA.framework/VISA")
import visa

But I get the same error.

Why can't the module be found? What am I missing?

UPDATE: I realized that PyVisa 1.5 was a development build, so I installed PyVisa 1.4 instead (I tried both MacPorts and just downloading the tarball and installing it manually). I'm still getting the same error.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Crystal
  • 137
  • 1
  • 2
  • 7
  • My application runs on OS 10.8.4 using NI-VISA 5.1.2 and PyVisa 1.4 so I think I can help. Just to make sure, after unpacking pyvisa, did you run the setup.py script (as instructed in the readme file)? If this was the issue, let me know and I'll add this as an answer. – Oren Sep 26 '13 at 12:02
  • Yes I did. I did finally got it to work by changing my PYTHONPATH and forcing python to run in 32-bit, but now other modules aren't working that I would expect to. Like argparse - I get errors about the wrong architecture. – Crystal Sep 26 '13 at 12:07
  • Wrong architecture with other modules? how did you solve the arch problem? I did this by using "arch -i386 python 2.7 MyScripy.Py" as my command to run the script. Did you do the same or did you change an arch related setting? – Oren Sep 26 '13 at 12:28
  • That didn't work for me. I found this on another site: `sudo lipo -thin i386 -output python-i386 /usr/bin/python2.7`. That gave me an executable 32-bit python that I use to run with my script. But when I try to import argparse, I get the architecture warnings. – Crystal Sep 26 '13 at 12:39
  • I'm no python expert but I would try to get the arch -i386 solution to work cause I know it worked for me and I had no problem with argparse in my visa application. What was the problem you encountered when trying to use that mode? If you open the terminal and type "arch -i386 python2.7" does it start python? – Oren Sep 26 '13 at 13:09
  • 1
    I hope I'm not wasting your time but I would also change to to NI-VISA 5.1.2 instead of NI-VISA 5.4. According to their description, the changes between versions were architecture related. See [VISA 5.1.2](http://joule.ni.com/nidu/cds/view/p/id/2915/lang/en) VS [VISA 5.4](http://joule.ni.com/nidu/cds/view/p/id/4235/lang/en) – Oren Sep 26 '13 at 13:24
  • Thanks. I'll try the NI-VISA change. I think I have other issues though. Yesterday I could run 'arch -i386 python2.7' but my python would still be 64bit. Today when I try to run the same command I get the error 'arch: posix_spawnp: python: Bad CPU type in executable'. – Crystal Sep 26 '13 at 14:52

0 Answers0