Skip to content
Advertisement

Issue with Constructor creation/File Referencing (AttributeError: ‘Sr830’ object has no attribute ‘resource_manager’)

I am relatively new to Python, so please bear with my lack of technical knowledge.

I have a lock-in amplifier setup with a GPIB to USB cable that is plugged into my computer. I am able to read the instrument fine with Pyvisa. I am additionally using other driver classes (labdrivers) to write and read values to and from the instruments.

Here is the __init__ method for the Python class I am referencing. There is of course more to it in terms of other methods that specifically run the commands using the instrument read from the resource manager, but I believe the error lies in this method when specifically reading the instrument. I have added three stars (***) to the beginning and end of the resourcemanager lines that are likely causing the issue for easier reference.

JavaScript

The code I am running on my test file is this.

JavaScript

The reason why I create the object using sr830.Sr830 is because this is the file path. anaconda3libsite-packageslabdriverssrssr830.py.

The error output from the terminal is this.

JavaScript

My files are in different directories. Could this be a possible issue? I am not sure if I am just creating the object wrong (I may be referencing the files incorrectly) or if there is some issue with pyvisa, although the pyvisa commands seem correct. I am running Python 3.9 on Spyder.

Please let me know any more information that I should provide. Thank you for all and any help.

Advertisement

Answer

I was able to resolve my issue. I believe the main problem was using a driver class written from someone else, which may have included other information or incompatible reference programs. By simply calling creating the Pyvisa resource manager object by myself in a separate file and passing information to the machine with the methods specified in the manual, the error no longer appeared. It is most likely necessary to make the methods simpler as well, as the driver methods included a great deal of other information which may have needed specific installations or versions of the supposed installations. It was not an issue of the files being in different directories. Additionally, I would advise making the class and file names as different as possible, as that led to some conflicts when I was creating objects. The file name was Sr830 which was similar to the class name of Sr830. This other error persisted despite my attempts to work around it, such as:

from labdrivers import Sr830

from Sr830 import Sr830

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement