Im using pyVisa to communicate with an OSA. After i move the files in folders to have a better structure, nothing works anymore. The structure is: ProjektFolder -> Includes -> VisaInstrument.py and ProjektFolder -> Instrument -> osa.py
In VisaInstrument.py the code is like this:
import pyvisa
...
class VisaInstrument():
def __init__(self, resource):
self.rm = pyvisa.ResourceManager()
self.resource = resource
self.instr = self.rm.open_resource(self.resource)
logging.debug('New lab object (resource %s) created.' % self.resource)
and in osa.py
from Includes import VisaInstrument
...
class osa(VisaInstrument.VisaInstrument):
def __init__(self, resource):
VisaInstrument.__init__(self, resource)
When i try to initialize the osa like this (in a different file):
from Instrument import osa
osaControl = osa.osa('GPIB0::14::INSTR')
i get following error message:
Traceback (most recent call last):
File "", line 1, in
File "C:\python\ProjektFolder\Instrument\osa.py", line 40, in init
VisaInstrument.init(self, resource)
TypeError: module() argument 1 must be str, not osa
With init as show in code not bold
can anyone tell me whats my mistake here?
The problem was: i didnt call VisaInstrument properly in class osa
from Includes import VisaInstrument
...
class osa(VisaInstrument.VisaInstrument):
def __init__(self, resource):
VisaInstrument.VisaInstrument.__init__(self, resource)
^this was missing