Python Developer interview question

How do you manage Python dependencies?

Manage Python dependencies with a declared project file and a reproducible lock, separate runtime from development dependencies, pin deployable environments, and update through tested, reviewable changes.

Direct answer

What a strong answer covers

How it works

Dependency management separates what the project declares from what gets installed. pyproject.toml lists direct dependencies with version ranges and optional groups for development and testing; a lock file records the exact resolved versions and hashes so every environment installs the same set. Tools such as uv, Poetry, or pip-tools produce the lock; virtual environments isolate projects; CI installs from the lock and fails when it drifts. Upgrades arrive as reviewed pull requests with tests, not as whatever pip resolved today.

Example

A service declares fastapi and sqlalchemy in pyproject.toml, commits uv.lock, and the Dockerfile runs uv sync --frozen so the image contains exactly the tested versions. Dependabot opens a pull request when a minor release of sqlalchemy appears, the test suite runs against it, and the lock changes only after review.

Common mistakes

  • Deploying from a requirements file with unpinned ranges and getting a different build each week.
  • Installing packages globally instead of into a per-project virtual environment.
  • Pinning everything by hand and never updating because the process is painful.

A useful answer structure

Answer from your own work.

Do not memorise a script: use only examples you can explain honestly in follow-up questions.

Practise this answer with MiraHint

Open the desktop workspace and rehearse a clear answer in your own words.

Download MiraHint
Python Developer interview questions