Python: 'ImportError: attempted relative import with no known parent package'
@devsingh05▲ 13 net votes
Relative imports (from .utils import x) work only when the file runs as part of a package. Running python app/main.py runs it as a top-level script. Run it as a module from the project root instead: python -m app.main (and add app/__init__.py if your tools need it), or switch to absolute imports. uvicorn app.main:app run from the root works for the same reason.