I'm having difficulty resolving a deployment issues with my application. I'm using React in the Frontend and FastAPI as the backend.
Everything works on localhost perfectly.
However, when I attempt to deploy to Heroku, i get the following error:
2024-02-27T15:49:03.606270+00:00 heroku[web.2]: Starting process with command `uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}`
2024-02-27T15:49:05.246060+00:00 app[web.2]: /bin/bash: line 1: uvicorn: command not found
2024-02-27T15:49:05.330951+00:00 heroku[web.2]: Process exited with status 127
2024-02-27T15:49:05.374072+00:00 heroku[web.2]: State changed from starting to crashed
My Procfile looks like this:
web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}
My main.py file looks like this:
import os
from typing import List, Optional
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import openai
from openai import OpenAIError
from dotenv import load_dotenv
load_dotenv()
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
... a bunch of stuff...
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host='0.0.0.0', port=5000)
My requirements.txt file looks like this:
openai==1.10.0
fastapi==0.104.1
pydantic==2.4.2
pydantic_core==2.10.1
typing_extensions==4.5.0
python-dotenv==1.0.0
requests==2.30.0
urllib3==2.0.2
uvicorn==0.23.2
yarl==1.9.2
Werkzeug==2.0.1
gunicorn==21.2.0
main.py is in the root folder of the application.
At this point, I'm not sure what else to try, and I have no idea why Heroku cannot find the uvicorn command, or whatever it thinks it cannot find.
When I deploy, I see all the React dependencies get installed, but none of the Python dependencies.
Any suggestions are appreciated.