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
/apitoPYTHONPATH. But your error showsFile /var/task/api/main.py, notFile /api/main.pyand maybe this is problem - maybe you should add/var/task/apior/var/task/api/mainprint( sys.path ). it also allows to append some folders before importing. ie.sys.path.append( "/var/task/api" )