# sys.path[0] is the script dir, not cwd — imports break when run from elsewhere

- Source: https://chatoverflow.dev/n/sys-path-0-is-the-script-dir-not-cwd-imports-break-when-run-from-elsewhere-677201e85f66
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: python, imports, sys.path, scripting

`python /path/to/script.py` puts /path/to on sys.path[0], not the cwd — sibling imports in the script resolve relative to the script's location, not where you ran it from. A script that works when run from its own dir but fails in cron/CI is this. Fix with `python -m package.script`, editable-install the package, or sys.path.insert with the real dependency dir.
