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.

classification
Title: adafruit_ads1x15.ads1115 not comaptible with globals()[pkg_trunc] = importlib.import_module(pkg_trunc)
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, jbrearley
Priority: normal Keywords:

Created on 2021-01-14 15:53 by jbrearley, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ada_dbg1.py jbrearley, 2021-01-14 15:53 uses simple hardcoded import statements, the creation of ads1115 objects work fine
ada_dbg2.py jbrearley, 2021-01-14 15:54 shows the issue, uses a loop to import a variable list of packages, which allows for more graceful error handling & messaging.
print_data.py jbrearley, 2021-01-14 15:55 utility to make output of dir(object) easier for humans to read
Messages (4)
msg385069 - (view) Author: John Brearley (jbrearley) Date: 2021-01-14 15:53
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?
msg385070 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-01-14 16:03
Sorry, this is not a help forum. Please try a user forum. Probably you have to find one with people using the Adafruit modules (and CircuitPython?).
msg385071 - (view) Author: John Brearley (jbrearley) Date: 2021-01-14 16:21
Hi Guido: So the Adafruit CircuitPython forum has already said they aren't really sure this is their issue or not, see: https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/issues/66

What else would I need to do to get this looked at by people knowledgeable in importlib.import_module?

Regards, John Brearley
613-259-5622 (Home)

From: Guido van Rossum 
Sent: 2021-01-14 11:03 AM
To: brearley@bell.net 
Subject: [issue42928] adafruit_ads1x15.ads1115 not comaptible with globals()[pkg_trunc] = importlib.import_module(pkg_trunc)

Guido van Rossum <guido@python.org> added the comment:

Sorry, this is not a help forum. Please try a user forum. Probably you have to find one with people using the Adafruit modules (and CircuitPython?).

----------
nosy: +gvanrossum
resolution:  -> third party
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue42928>
_______________________________________
msg385073 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-01-14 18:27
They did not imply it was a bug, just that they don't know enough about Python to be able help you.

As I said, this tracker is not a help forum (you're taking valuable time away from core developers). Try this forum: https://discuss.python.org/c/users/7 .
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87094
2021-01-14 18:27:34gvanrossumsetmessages: + msg385073
2021-01-14 16:21:23jbrearleysetmessages: + msg385071
2021-01-14 16:03:10gvanrossumsetstatus: open -> closed

nosy: + gvanrossum
messages: + msg385070

resolution: third party
stage: resolved
2021-01-14 15:55:39jbrearleysetfiles: + print_data.py
2021-01-14 15:54:40jbrearleysetfiles: + ada_dbg2.py
2021-01-14 15:53:34jbrearleycreate