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

`bash: .venv/bin/activate: No such file or directory` in a CI job, although the venv was created in an earlier step.

IntermediateTroubleshootingEnvironments, imports & packaging errors
Answer

Likely causes → The working directory changed, the venv was created in a different job (jobs do not share filesystems), or python3-venv is missing so creation failed silently earlier (ensurepip is not available).

Diagnose →

pwd; ls -la .venv/bin 2>&1
python3 -m venv .venv; echo $?

Fix → Create the venv in the same job, use absolute paths, install python3-venv on Debian/Ubuntu runners, or use actions/setup-python and skip the venv.

Prevent → Each CI job is a fresh machine; share artifacts or caches explicitly.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, imports & packaging errors