What are the two main tools/concepts used for dependency management?
1. Virtual Environments (like venv or conda) for project isolation. 2. Package Managers (like pip) for installing and tracking packages.
What is the role of a virtual environment in dependency management?
It creates a sandbox where packages are installed only for that specific project, preventing version conflicts with other projects or the global Python installation.
What is a dependency file and what is the standard name?
A simple text file that lists all the required Python packages and their specific versions for a project. The standard name is requirements.txt.
What is the command to generate the standard dependency file?
pip freeze > requirements.txt (Run this inside an active virtual environment).
What is the command to install all dependencies for a new developer or deployment?
After activating the environment, use: pip install -r requirements.txt
When should you update the dependencies in your project?
When you need a new package, or when you upgrade an existing package (e.g., using pip install --upgrade pkg_name). You must then immediately run pip freeze > requirements.txt.
What is a lock file and how is it different from requirements.txt?
A lock file (often auto-generated, like Pipfile.lock or poetry.lock) lists all direct and transitive dependencies (dependencies of dependencies) at exact versions, ensuring perfect reproducibility.
Which third-party tools offer more advanced dependency management than pip alone?
Poetry and Pipenv. They combine environment management and dependency tracking, often using dedicated lock files and manifest files (like pyproject.toml).