Here is my file structure and requirements.txt:

Getting ModuleNotFoundError, any help will be appreciated.
main.py
from fastapi import FastAPI
from .import models
from .database import engine
from .routers import ratings
models.Base.metadata.create_all(bind=engine)
app = FastAPI()
app.include_router(ratings.router)
The error comes from the fact that you were not using the right environment and python version on VSCODE. Your environment knew your different packages, but VSCode probably did not take them into account.
The solution was, in VSCODE: CTRL + SHIFT + P then Python:select interpreter and choose the version of python linked to your environment.
You can try to change the version of python to see the consequences on your imports
Try this to install all dependencies:
$ pip install "fastapi[all]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With