Replies: 9 comments 12 replies
-
@ninest Did you found solution to import file? |
Beta Was this translation helpful? Give feedback.
-
@ninest I found solution. Original project structure (Not working)
I moved |
Beta Was this translation helpful? Give feedback.
-
If you set
or
cf. vercel.json is like this.
|
Beta Was this translation helpful? Give feedback.
-
Solution? |
Beta Was this translation helpful? Give feedback.
-
I have a similar problem. My project is structured as follows:
Inside server.py I have the following code:
And my vercel.json:
Vercel gives me the following error: Locally my project runs correctly. Moreover, if in server.py I don't use any import and I simply write Any solution? Thank you! |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
You can add the environment variable "env": {
"PYTHONPATH": "api/"
} |
Beta Was this translation helpful? Give feedback.
-
can somehow share a working solution? |
Beta Was this translation helpful? Give feedback.
-
After seeing this comment, I learned that to import a function in your Python API, you have to put an underscore before the file name.
I tried this method but it doesn't seem to work. I have
_utils/common.py
inside myapi/
directory.My
index.py
looks like this:When I try to visit any API route, I get this error:
Everything works fine when I run the code with
python3 api/index.py
, but usingvercel dev
causes this error. It comes as a 502: bad gateway error.Is there an official example I can refer to?
Beta Was this translation helpful? Give feedback.
All reactions