The issue seems to be a little more complex, than I initially described.
The attached script ada_dbg1.py sets up ads1115 objects using standard import command with hardcoded list of modules, works OK.
In particular, "ads10 = adafruit_ads1x15.ads1115.ADS1115(i2c_1, address=0x48)" works, which is getting to where I want to be.
The attached script ada_dbg2.py sets up ads1115 objects using a loop with error handling to load a string list of modules via:
- Code: Select all | TOGGLE FULL SIZE
globals()[pkg_trunc] = importlib.import_module(pkg_trunc)
The same line of code creating ads10 gets error:
Traceback (most recent call last):
File "ada_dbg2.py", line 33, in <module>
ads10 = adafruit_ads1x15.ads1115.ADS1115(i2c_1, address=0x48)
AttributeError: module 'adafruit_ads1x15' has no attribute 'ads1115'
When I look at the global variables, from ads_dbg1.py, I see:
'adafruit_ads1x15': <module 'adafruit_ads1x15' from '/home/pi/.local/lib/python3.7/site-packages/adafruit_ads1x15/__init__.py'>,
When I look at the global variables, from ads_dbg2.py, I see:
'adafruit_ads1x15.ads1115': <module 'adafruit_ads1x15.ads1115' from '/home/pi/.local/lib/python3.7/site-packages/adafruit_ads1x15/ads1115.py'>,
So I tried doing the import without the .ads1115 appended, & got:
'adafruit_ads1x15': <module 'adafruit_ads1x15' from '/home/pi/.local/lib/python3.7/site-packages/adafruit_ads1x15/__init__.py'>,
But I still get an error.
Traceback (most recent call last):
File "ada_dbg2.py", line 33, in <module>
ads10 = adafruit_ads1x15.ads1115.ADS1115(i2c_1, address=0x48)
AttributeError: module 'adafruit_ads1x15' has no attribute 'ads1115'
Suggestions?