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

`pip install` on `python:3.12-alpine` takes 15 minutes and ends with `error: command 'gcc' failed: No such file or directory`.

IntermediateTroubleshootingEnvironments, imports & packaging errors
Answer

Likely causes → No prebuilt musllinux wheel for a package (or its version), so pip builds from sdist, which needs a compiler and headers.

Diagnose →

pip install -v <pkg> 2>&1 | grep -E "Building wheel|Downloading .*\.tar\.gz"

Fix → Switch to python:3.12-slim (glibc, manylinux wheels exist for almost everything). If you must use Alpine, install build deps in a builder stage (apk add build-base libffi-dev) and copy only the built wheels.

Prevent → Default to slim for Python images; check wheel availability before choosing a base.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, imports & packaging errors