How do you manage dependencies in python projects? (AI) Flashcards

(8 cards)

1
Q

What are the two main tools/concepts used for dependency management?

A

1. Virtual Environments (like venv or conda) for project isolation. 2. Package Managers (like pip) for installing and tracking packages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the role of a virtual environment in dependency management?

A

It creates a sandbox where packages are installed only for that specific project, preventing version conflicts with other projects or the global Python installation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a dependency file and what is the standard name?

A

A simple text file that lists all the required Python packages and their specific versions for a project. The standard name is requirements.txt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the command to generate the standard dependency file?

A

pip freeze > requirements.txt (Run this inside an active virtual environment).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the command to install all dependencies for a new developer or deployment?

A

After activating the environment, use: pip install -r requirements.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When should you update the dependencies in your project?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a lock file and how is it different from requirements.txt?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which third-party tools offer more advanced dependency management than pip alone?

A

Poetry and Pipenv. They combine environment management and dependency tracking, often using dedicated lock files and manifest files (like pyproject.toml).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly