This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jbrearley
Recipients jbrearley
Date 2021-01-14.15:53:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610639614.07.0.761554562908.issue42928@roundup.psfhosted.org>
In-reply-to
Content
The first attached script ada_dbg1.py.txt which uses simple hardcoded import statements, the creation of ads1115 objects work fine. The second attached script ada_dbg2.py.txt uses a loop to import a variable list of packages, which allows for more graceful error handling & messaging.

globals()[pkg_trunc] = importlib.import_module(pkg_trunc)

The high level observation is that board, busio & adafruit_extended_bus objects continue to be correctly created after the import loop is done. Its just adafruit_ads1x15.ads1115 that does not like this import method.

The same line of code creating ads10 gets error:
Traceback (most recent call last):
File "ada_dbg2.py", line 33, in
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
ads10 = adafruit_ads1x15.ads1115.ADS1115(i2c_1, address=0x48)
AttributeError: module 'adafruit_ads1x15' has no attribute 'ads1115'

I went through all 8 permutations of with/without the .ads1115 in the importlib.import_module statement, no luck.

Comments?
History
Date User Action Args
2021-01-14 15:53:34jbrearleysetrecipients: + jbrearley
2021-01-14 15:53:34jbrearleysetmessageid: <1610639614.07.0.761554562908.issue42928@roundup.psfhosted.org>
2021-01-14 15:53:33jbrearleylinkissue42928 messages
2021-01-14 15:53:33jbrearleycreate