Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastapi cannot run in python 3.12 #912

Open
zhugezifang opened this issue May 9, 2024 · 1 comment
Open

fastapi cannot run in python 3.12 #912

zhugezifang opened this issue May 9, 2024 · 1 comment

Comments

@zhugezifang
Copy link

fastapi cannot run in python 3.12

@peterdresslar
Copy link

peterdresslar commented Sep 12, 2024

A workaround is to add the Pipfile as suggested here:

https://vercel.com/docs/functions/runtimes/python#python-version

...setting python_version = "3.9" ... and note that you may be able to just run your fastapi app normally without anything else special like a vercel.json file. As of now, seems to work fine with Node 20.x.

Note that the official example here:

https://github.com/digitros/nextjs-fastapi/

...somewhat buries the issue by including a 3.9.pyc file that apparently controls Vercel's selection of version during build. Unfortunately, this obfuscates the issue, somewhat violates the convention in the docs linked above, and anyway including /__python__ in the checked in files seems unusual.

Here's an example of nextjs, fastapi, and postgres working with Pipfile:

https://github.com/peterdresslar/fullstack-nextjs-fastapi-postgres

It deploys and works as-is; if python_version is incremented to 3.12, the build succeeds but the API itself 404s.

UPDATE:

Downgrading to 3.9, deploying, then upgrading the Pipfile to 3.12 and re-deploying, makes the example work now. Slowly, I'd point out, but it works. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants