Skip to content

Conversation

@dhalbert
Copy link
Collaborator

On the smallest boards, we use terse error messages to save space. Usually this is fine, but the module not found error is confusing, because on casual glance it can make it appear that a module being imported is missing, instead of some subsequent import being missing. Use the regular more verbose message instead, which names the missing module.

I've seen several users be confused by this and resort to asking a support question. This happened most recently in discord.

Example and test:

Old way, which causes a number of users to say, "but I did add neopixel as a library":

Adafruit CircuitPython 10.0.0-beta.3 on 2025-08-29; Adafruit Gemma M0 with samd21e18
>>> import neopixel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "neopixel.py", line 17, in <module>
ImportError: module not found

Clearer message:

Adafruit CircuitPython 10.0.0-beta.3-12-gc382b55a6d-dirty on 2025-09-11; Adafruit Gemma M0 with samd21e18
>>> import neopixel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "neopixel.py", line 17, in <module>
ImportError: no module named 'adafruit_pixelbuf'

Copy link
Collaborator

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I tested successfully on a TrinketM0 using a build from this branch and do see the complete error now:

code.py output:
Traceback (most recent call last):
  File "code.py", line 5, in <module>
  File "neopixel.py", line 17, in <module>
ImportError: no module named 'adafruit_pixelbuf'

@dhalbert dhalbert merged commit 11ecd40 into adafruit:main Sep 11, 2025
627 checks passed
@dhalbert dhalbert deleted the verbose-import-error branch September 11, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants