[New-bugs-announce] [issue42928] adafruit_ads1x15.ads1115 not comaptible with globals()[pkg_trunc] = importlib.import_module(pkg_trunc)
John Brearley
report at bugs.python.org
Thu Jan 14 10:53:34 EST 2021
New submission from John Brearley <brearley at bell.net>:
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?
----------
components: Interpreter Core
files: ada_dbg1.py
messages: 385069
nosy: jbrearley
priority: normal
severity: normal
status: open
title: adafruit_ads1x15.ads1115 not comaptible with globals()[pkg_trunc] = importlib.import_module(pkg_trunc)
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49741/ada_dbg1.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42928>
_______________________________________
More information about the New-bugs-announce
mailing list