Python in production · Scenario
A deploy breaks because a dependency of a dependency changed
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Nothing changed in our code, but this morning's deploy of a Python service failed: the new container crashes on start with an ImportError from a library we don't even use directly. Yesterday's build was fine. What happened, and how do you fix it properly?
Then
Follow-ups the interviewer asks next
- What do you do in the first 15 minutes?
- How do you find which package changed?
- Why did "nothing changed" still break?
- You pin that one package and pip now fails with
ResolutionImpossible. Why? - How do lock files work with pip-tools, Poetry and uv?
- How do you still get security updates without surprises?
- Have you had a build break like this?
The answer
What a strong answer covers
- First: redeploy yesterday's image (images are immutable; that's why you keep them).
- Find it: diff
pip freeze(oruv pip list) between the two images. - Cause:
requirements.txtlists only direct dependencies with open ranges, so every build resolves fresh and picked up a new major version of a transitive package. - The twist: a direct dependency also released a version that needs the new major, so one pin conflicts. Lock everything, not one package.
- Lock files with exact versions and hashes: pip-tools (
pip-compile --generate-hashes), Poetry (poetry.lock), uv (uv.lock;uv sync --lockedfails if the lock is out of date). PEP 751 defines a standardpylock.toml; uv can export it and pip has experimental support. - Applications lock; libraries declare ranges.
- Updates: Dependabot or Renovate pull requests tested in CI; build once and promote the same image.
The red pen
Common traps
Avoid:pip install --upgrade everything; deleting the upper bounds to "fix" the conflict.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.