webworm84
webworm84

Reputation: 452

When vercel deploying my python app gives Error: Unable to find any supported Python versions

While installing the web app I prepared using python, vertex ai google chat bison model and fastapi, I constantly get Error: Unable to find any supported Python versions error and the installation does not complete. I also specified the Python version in the Requirements file, but it did not help. I use Vercel with github and all my files are in the root directory. My vercel deployment error screenshot is like this:

enter image description here

My files are app.py, .env , Procfile , requirements.txt and vercel.json. The contents of some files are as follows:

.env file:

GOOGLE_API_KEY=MYAPIKEY

Procfile:

web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:app

requirements.txt:

fastapi==0.110.0

markdown==3.6

python-dotenv==1.0.1

gunicorn==21.2.0

uvicorn==0.29.0

uvicorn-worker==0.1.0

python-multipart==0.0.9

google-generativeai==0.4.1

google-cloud-aiplatform==1.44.0

python==3.9.0

vercel.json:

{
  "devCommand": "gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:app",
  "builds": [
    {
      "src": "/app.py",
      "use": "@vercel/python"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "/app.py"
    }
  ]
}

My project runs very well on my computer in the VsCode environment, but I am having this problem when deploying on Vercel.

I tried editing the vercel.json file many times. I updated the versions of the requirements in the requirements.txt file, i set the python version to 3.9.0 which is supported by vercel at requirements file but it did not solve my problem. I would be very happy if you could help me with what I can do.

Upvotes: 3

Views: 1511

Answers (4)

neaph
neaph

Reputation: 11

I used Vercel's own Flask template and replicated it for FastAPI, and everything went well.

Here are the configuration files:

vercel.json:

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

package.json : "node": "18.x"

Additionally, I'm providing the test code: https://github.com/neaphdev/fastapi-vercel

ª   package.json
ª   requirements.txt
ª   vercel.json 
+---api
ª       index.py
ª       
+---app
        app.py

Upvotes: 1

Viral Gajera
Viral Gajera

Reputation: 24

I resolved the issue by adding package.json file into the project directory and specifying the node version to 18.x.

Adding the following content into package.json

{
    "engines": {
        "node": "18.x"
    }
}

Project Directory :

Project Directory

Upvotes: 0

Kauan Sena
Kauan Sena

Reputation: 71

I opened a thread about the same issue on vercel's github. In my case, even downgrading to node 18.x, the building error persists as "Error: Unable to find any supported Python versions".

This has never happened before using vercel’s own templates

https://github.com/orgs/vercel/discussions/6287

Upvotes: 0

Thijmen Kurk
Thijmen Kurk

Reputation: 41

I had the same issue just now, resolved it by downgrading the Node.js version from 20.x to 18.x in Project Settings.

Upvotes: 4

Related Questions