What is Python's virtual environment and dependency management?
Why Interviewers Ask This
This tests whether you can apply Python knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Python dependency management has evolved significantly. pip is the standard package installer. requirements.txt pins dependencies: pip freeze > requirements.txt, install with pip install -r requirements.txt. Poetry is the modern standard: manages dependencies (pyproject.toml), lock file (poetry.lock), virtual env, and building/publishing. Commands: poetry add requests, poetry install, poetry run python app.py. Pipenv combines pip and venv with Pipfile and Pipfile.lock. conda manages both Python packages and non-Python dependencies — popular in data science. pyproject.toml (PEP 518) is the modern standard for project metadata, replacing setup.py. Use pip-tools for reproducible builds: compile requirements with version pinning. Virtual environments isolate project dependencies, preventing conflicts between projects.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Python candidates.
Previous
What is Python's requests library?
Next
What is Python's context managers and the contextlib module?