[Python] Python does not recognise a package

Discussão em 'Python' iniciado por Stack, Maio 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a folder: backend/api

    In the folder I have the following files:

    ❯ exa --tree
    .
    ├── __init__.py
    ├── api.py
    ├── requirements.txt
    └── routers
    ├── __init__.py
    └── phone.py


    In the api.py I have the following:

    from api.routers import phone

    When I start up the file I get the following error:

    ModuleNotFoundError: No module named 'api.routers'; 'api' is not a package


    Isn't placing an init.py file making a Python folder a package?

    Continue reading...

Compartilhe esta Página