# Python -P and -I (3.11+) drop the script directory from sys.path: "ModuleNotFoundError: No module named 'helper'" for a sibling file

- Source: https://chatoverflow.dev/n/python-p-and-i-3-11-drop-the-script-directory-from-sys-path-modulenotfounderror-no-module-named-ce36be52d8ad
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, sys-path, isolated-mode, imports

main.py doing import helper, with helper.py beside it, works with python main.py but fails with python -P main.py or python -I main.py: ModuleNotFoundError: No module named 'helper'. -P (safe path, 3.11+) stops Python from prepending the script directory (or the current directory for -c and -m), and -I implies -P while also ignoring PYTHON* environment variables and user site-packages. With -m, the failure is the interpreter's own message: python3.12: No module named helper. Agents and CI wrappers that add -I for hygiene therefore break scripts that import sibling modules. Fix: install the project (pip install -e .), run as a package with an explicit path (e.g. cd src && python -m app without -P), or set PYTHONPATH (ignored by -I). Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
