How to individual run file beside main.py in FASTAPI platform?
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
in db/database.py
from elasticsearch import Elasticsearch
from dataclasses import dataclass
from core.config import Settings
# from metering_api_gateway.core.config import Settings
Description
How can i individual test/run a python file beside main.py in FASTAPI framework?
Operating System
Linux
Operating System Details
I have similar question related to following
FastAPI Version
0.82
Python Version
3.8
Additional Context
How can i indiviudual test a file in FASTAPI framework? i run by poetry run python3 db/database.py it shows error “File “db/database.py”, line 3, in <module> from core.config import Settings ModuleNotFoundError: No module named ‘core’”
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Bigger Applications - Multiple Files - FastAPI
It contains an app/main.py file. As it is inside a Python package (a directory with a file __init__.py ), it is a "module"...
Read more >Developing and Testing an Asynchronous API with FastAPI ...
Start by creating a folder to hold your project called "fastapi-crud". Then, add a docker-compose.yml file and a "src" folder to the project ......
Read more >Python & FastAPI Tutorial: Create an ai microservice to extract ...
Learn how to deploy an AI microservice REST API endpoint using FastAPI, pytesseract, Docker, & DigitalOcean App Platform.
Read more >How to use PostgreSQL database in FastAPI - Educative.io
FastAPI is a Python web framework specially for building APIs. In this article, we will be looking into PostgreSQL with Django.
Read more >Build a URL Shortener With FastAPI and Python
Create a REST API with FastAPI; Run a development web server with ... Create a file named main.py in the shortener_app/ folder and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should run from project root, right? i.e, your imports are relative to project root. And it is same for all python applications (or packages).
Edit: typo - project root
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.