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

`ImportError: attempted relative import with no known parent package` when running `python cloudaudit/cli.py`.

IntermediateTroubleshootingEnvironments, imports & packaging errors
Answer

Likely causes → Running a module file directly makes it __main__ with no package context, so from .checks import ... cannot resolve.

Diagnose →

head -20 cloudaudit/cli.py | grep "from \."

Fix → Run it as a module from the project root: python -m cloudaudit.cli, or install the package (pip install -e .) and use the console script cloudaudit.

Prevent → Use the src/ layout with entry points; never run package modules by file path.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, imports & packaging errors