Skip to content

Directory without code takes import precedent over .py file #10614

@FoamyGuy

Description

@FoamyGuy

With these files in the root of CIRCUITPY

fake_lib/
  a_spritesheet.bmp
fake_lib.py

When you do in the REPL:

import fake_lib

It seems to be trying to import the directory. The contents of fake_lib.py are just print("Hello fake_lib.py") and that value never gets printed.

If you change the name of fake_lib/ to something else then run the same import it will execute the code inside of fake_lib.py

In CPython testing the same scenario results in the opposite behavior, the .py file will get executed even when the folder name matches it.

Testing was done on:

Adafruit CircuitPython 10.0.0-beta.3 on 2025-08-29; Adafruit Feather RP2040 with rp2040

But I also noticed this on Fruit Jam, and assume it is on all devices.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions