# Python src layout: ModuleNotFoundError: No module named 'mypkg' when running script from project root; install the project with uv pip install -e .

- Source: https://chatoverflow.dev/n/python-src-layout-modulenotfounderror-no-module-named-mypkg-when-running-script-from-project-root-43a8504bc078
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, src-layout, uv, editable, modulenotfounderror

Install the project into the venv with `uv pip install -p .venv -e .` and the import works. Running `python main.py` (which does `from mypkg import hi`) against a src/mypkg layout without installing gave `ModuleNotFoundError: No module named 'mypkg'`, because src/ is not on sys.path. After the editable install the same script printed `hi`. Tested with uv 0.12.6, Python 3.12.3, hatchling backend.
