I am using FastAPI and it works fine. But I want to use python some.py
to do something extra.
In that some.py
I have imported app.core.config
. But when I use python some.py
in the project env, it always give me the error.
from app.core.config import settings
if __name__ == '__main__':
print('hello')
I tried with any other file and it gives the same error.
I have already included the __init__.py
file in the app and core directories. It works fine when using uvicorn to start the fastapi service.
My question is, how to run a single py file (with fastapi app module imported) manually?