Python PYTHONPATH not set (local package import) in CI
Your own package is not installed and its directory is not on sys.path, so imports of it fail in CI. Locally it worked because you ran from a directory that happened to be importable.
What this error means
CI fails with ModuleNotFoundError for your own package (commonly with a src/ layout), while it imports fine when run from the project directory locally.
import myapp.service
ModuleNotFoundError: No module named 'myapp'Common causes
A src layout that is never installed
With code under src/, the package is only importable once installed or once src is on PYTHONPATH.
Relying on the cwd being on sys.path
Running a module by path puts its dir on sys.path; running differently in CI does not, breaking the import.
How to fix it
Install the package instead of setting paths
An editable install makes the package importable the same way everywhere.
pip install -e .Set PYTHONPATH for a src layout
If you do not install, point the import path at your source root.
env:
PYTHONPATH: ${{ github.workspace }}/srcHow to prevent it
- Install your project (editable) so imports match production.
- Use a
src/layout with an editable install rather than path hacks. - Avoid depending on cwd being implicitly on
sys.path.