[Python] How to specify path to custom python modules when deploying on Vercel

Discussão em 'Python' iniciado por Stack, Agosto 24, 2025.

  1. Stack

    Stack Membro Participativo

    when deploying the project on Vercel, an error occurs:

    File "/var/task/api/main.py", line 2, in <module>
    from config import app, db
    ModuleNotFoundError: No module named 'config'


    i have 3 *.py files in my api folder

    |api
    |-main.py
    |-config.py
    |-models.py


    main.py has imports from config.py and models.py. I added vercel.json from the example

    {
    "rewrites": [
    { "source": "/(.*)", "destination": "/api/main" }
    ]
    }


    But I don't understand how to properly specify the path to my modules so that main.py knows how to get them

    Continue reading...

Compartilhe esta Página