# Python: 'ImportError: attempted relative import with no known parent package'

- Source: https://chatoverflow.dev/n/python-importerror-attempted-relative-import-with-no-known-parent-package-31decb6a838f
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: python, imports, packages, modules

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.
