Sakulas
Sakulas

Reputation: 1

pyvisa-py on raspberry pi AttributeError: 'module' object has no attribute 'ResourceManager'

py on a raspberry pi with python 2.7.9 and pip 1.5.6. I installed and uninstalled pyvisa and pyvisa-py several times, but the problems stay. I connected the KEITHLEY Multimeter 2000 per R232 to USB with the Raspberry.

When I run the basic Code: import visa rm = visa.ResourceManager('@py') a=rm.list_resources() print(a) I receive: Traceback (most recent call last): File "pyvisa.py", line 1, in <module> import visa File "/usr/local/lib/python2.7/dist-packages/visa.py", line 16, in <module> from pyvisa import logger, __version__, log_to_screen, constants File "/home/pi/pyvisa.py", line 2, in <module> rm = visa.ResourceManager('@py') AttributeError: 'module' object has no attribute 'ResourceManager'

as well when I try

python -m visa info

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/local/lib/python2.7/dist-packages/visa.py", line 16, in <module> from pyvisa import logger, __version__, log_to_screen, constants File "pyvisa.py", line 1, in <module> import visa File "/usr/local/lib/python2.7/dist-packages/visa.py", line 16, in <module> from pyvisa import logger, __version__, log_to_screen, constants ImportError: cannot import name logger On the other hand i can't upgrade, because the requirements are already up-to-date. pip install pyvisa-py --upgrade Requirement already up-to-date: pyvisa-py in /usr/local/lib/python2.7/dist-packages Requirement already up-to-date: pyvisa>=1.8 in /usr/local/lib/python2.7/dist-packages (from pyvisa-py) Requirement already up-to-date: enum34 in /usr/local/lib/python2.7/dist-packages (from pyvisa>=1.8->pyvisa-py) I would be very thankfull if somebody could help me with this issue.

Upvotes: 0

Views: 3009

Answers (2)

Chad
Chad

Reputation: 141

visa.py module does not have ResourceManager() you must instead use pyvsa.py

import pyvisa

rm = pyvisa.ResourceManager('@py')
a=rm.list_resources()
print(a)

There will be no error if you run this code, you should be able to print whatever instrument is connected.

Upvotes: 1

Sakulas
Sakulas

Reputation: 1

"In python 2.7, the import system will always use files in the working directory over the one in site-packages and as your file is named pyvisa.py when importing visa.py it picks your own module instead of the 'real' pyvisa module."MatthieuDartiailh from github

Upvotes: 0

Related Questions