ibra
ibra

Reputation: 116

Issues when importing modules on AWS AppRunner (Python 3.11)

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 :

Everything worked perfectly fine, and I tried to deploy it with Python 3.11 with the following commands :

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

Answers (0)

Related Questions