Interview Prep/Python for DevOps/Environments, imports & packaging errors

In VS Code tests pass, but in the terminal `pytest` shows `ModuleNotFoundError: No module named 'cloudaudit'`.

BeginnerTroubleshootingEnvironments, imports & packaging errors
Answer

Likely causes → The package is not installed in the active venv (IDE sets PYTHONPATH or uses a different interpreter), or pytest on PATH is a global one.

Diagnose →

which pytest; python -m pytest --version
python -c "import cloudaudit, sys; print(cloudaudit.__file__, sys.executable)"

Fix → pip install -e ".[dev]" in the venv and run python -m pytest. Or set pythonpath = ["src"] in [tool.pytest.ini_options].

Prevent → Install the project into its venv; avoid relying on IDE path magic.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, imports & packaging errors