Python Developer Interview Question

How do you set up dependencies and environments on a new Python project?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Declare everything in pyproject.toml and manage the environment with uv, which creates the virtual environment, resolves dependencies, and writes a lock file quickly. Keep direct dependencies loose in the project table, commit the lock file for reproducible installs, and separate development tools into dependency groups so production images do not ship pytest and ruff.

Why interviewers ask this

Packaging is where Python has historically been painful, so the interviewer is checking you are current rather than still copying a requirements file workflow from a decade ago. They want the distinction between declared dependencies and a lock file, awareness that pyproject.toml is the standard place for configuration, and evidence you have thought about reproducible builds in CI and Docker.

How to structure your answer

  • Name pyproject.toml as the single source of truth.
  • Separate declared ranges from the lock file.
  • Split runtime and development dependency groups.
  • Tie it to CI and container builds.

Example answer

Spoken example, first person

Everything lives in pyproject.toml: the dependencies, the tool configuration for ruff and mypy and pytest, the build metadata. I use uv to drive it, because it creates the venv, resolves, and installs fast enough that a cold CI environment is seconds rather than minutes, and it manages the interpreter version too so nobody is fighting over which Python is on the path. Direct dependencies get reasonably loose constraints, then uv lock produces the exact resolved set and that lock file is committed. CI and Docker install from the frozen lock, so what runs in production is bit for bit what I tested. Development tools go in a separate group, which keeps the runtime image smaller and means a compromised linter is not sitting in the production container. In Docker I copy the lock and manifest first and install before copying source, so layer caching actually works. Migrating an older project off pip and requirements files took maybe an afternoon and cut our CI setup step by several minutes.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What does the lock file protect you from?
  • How do you handle a dependency that has no wheel?
  • How do you manage multiple Python versions locally?

Related python developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot