Reputation: 116
I'm relatively new to AWS AppRunner, and I'm trying to deploy a simple FastAPI endpoint to perform some tests. Here is the main.py
file :
from fastapi import FastAPI
import uvicorn
from pydantic import BaseModel
import numpy as np
app = FastAPI()
class InputNumber(BaseModel):
value: float
@app.post("/sqrt")
async def compute_sqrt(input_data: InputNumber):
result = np.sqrt(input_data.value)
return {"result": float(result)}
if __name__ == '__main__':
uvicorn.run(app, port=8080, host='0.0.0.0')
With this code, I have of course a requirements.txt
file :
fastapi
uvicorn[standard]
numpy
pydantic
At first, I tried to deploy it with Python 3
, and the following commands :
pip install -r requirements.txt
python main.py
Everything worked perfectly fine, and I tried to deploy it with Python 3.11
with the following commands :
pip3 install -r requirements.txt
python3 main.py
The build is working fine, but I'm getting an unexpected error when the deployment starts:
ModuleNotFoundError: No module named 'fastapi'
The build was correctly performed (every lib was downloaded as seen in the logs), and the same error occurs when adding a version to the libs in the requirements.txt
file.
I don't have docker
Thanks in advance !
Upvotes: 0
Views: 50