PrepPilotPractise free

Python Packaging & Tooling interview questions

venv, pip, poetry/uv, pyproject, linting and testing tools

17 questions · pip · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is a Python virtual environment and why should you use one?

A virtual environment is an isolated Python environment that keeps project dependencies separate from the global Python installation. Using one prevents conflicts between packages and ensures reproducibility.

How do you install packages using pip from a requirements file?

You install packages listed in a requirements file by running pip install -r requirements.txt. This installs all dependencies specified in the file.

What is the purpose of a lock file in Python packaging?

A lock file records the exact versions of all installed dependencies, ensuring that everyone working on the project uses the same package versions for consistency and reproducibility.

How do you activate a virtual environment created with venv?

On Unix systems, you run source myenv/bin/activate; on Windows, it's myenv\Scripts\activate. This switches your shell to use the environment's Python and packages.

Intermediate questions

What are the advantages of using Poetry or uv over pip for dependency management?

Poetry and uv provide better dependency resolution, automatic lock file generation, and integrate with pyproject.toml for configuration. They also simplify publishing packages and managing virtual environments, making workflows more robust and reproducible.

How does pyproject.toml improve Python packaging compared to setup.py?

pyproject.toml standardizes build configuration and supports multiple build backends. It's easier to read and maintain, and enables interoperability between tools like Poetry, uv, and flit, replacing the older, less flexible setup.py approach.

Explain how you would resolve a dependency conflict in a Python project.

I'd check which packages require conflicting versions, review their requirements, and try to upgrade or downgrade dependencies to compatible versions. Tools like Poetry or uv can help identify and resolve conflicts automatically, but sometimes manual intervention is needed.

What does pinning dependencies mean and why is it important?

Pinning means specifying exact versions of dependencies, like requests==2.31.0. It's important because it prevents unexpected updates that could break your code or introduce conflicts, ensuring stable and reproducible builds.

How do you use ruff and black in a project?

I run ruff check to lint the code and catch errors, and black to auto-format code to a consistent style. Both tools can be integrated into CI pipelines to enforce code quality and style across the team.

What is type checking in Python and how do you implement it?

Type checking uses tools like mypy to validate type annotations in your code. You add type hints to functions and classes, then run mypy to catch type errors before runtime, improving reliability and documentation.

Describe the structure of a basic pytest test file.

A pytest test file contains functions prefixed with test_. You can use fixtures for setup, and assertions to check expected outcomes. Tests are discovered automatically by pytest based on naming conventions.

How do you use pytest fixtures to avoid code duplication in tests?

Fixtures provide reusable setup and teardown logic. You define them with @pytest.fixture, then pass them as arguments to test functions, keeping tests DRY and maintainable.

How does pytest parametrize help in writing better tests?

See the answer in the app, free

Senior questions

How would you design a Python package for distribution using pyproject.toml?

See the answer in the app, free

How do you ensure your Python codebase is free from dependency conflicts in CI/CD?

See the answer in the app, free

How would you set up comprehensive testing and coverage for a Python project?

See the answer in the app, free

Describe a workflow for maintaining code quality in a large Python project.

See the answer in the app, free

More Python topics