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

`ModuleNotFoundError: No module named 'boto3'` right after you ran `pip install boto3`.

BeginnerTroubleshootingEnvironments, imports & packaging errors
Answer

Likely causes → pip belongs to a different interpreter than python (system vs venv, python3.11 vs python3.12), or the venv is not activated in this shell, or cron/systemd uses the system Python.

Diagnose →

which python pip; python -c "import sys; print(sys.executable)"
pip --version            # shows which Python it installs into
python -m pip show boto3

Fix → Install with the interpreter you run: python -m pip install boto3. In cron/systemd, call /opt/tool/.venv/bin/python explicitly.

Prevent → Always use python -m pip; use console-script entry points or absolute venv paths in schedulers.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, imports & packaging errors