pip installs packages from PyPI into the active Python environment. Pin versions in requirements.txt or pyproject.toml for reproducible builds—like NuGet in C# or npm for Node.
Common commands (local)
pip install requests
pip install "django>=4.2,<5"
pip freeze > requirements.txt
pip install -r requirements.txt
Playground vs local
Third-party packages (Django, requests, pandas) are not available in the sandbox—simulate patterns with stdlib here, then install locally. Django lessons start in the Django track.
Important interview questions and answers
- Q: pip vs conda?
A: pip is Python's default package installer from PyPI; conda manages binaries and non-Python deps in Anaconda ecosystems. - Q: Why pin versions?
A: Prevents surprise breaking upgrades in CI and production—reproducible installs.
Self-check
- What file lists pinned dependencies?
- Can you pip install Django in the playground?
Pitfall: Pin versions in CI—pip install django without constraints can pull breaking updates.
Interview prep
- pip freeze purpose?
Capture installed versions into requirements.txt for reproducible installs.
- Playground pip packages?
Third-party packages need local pip—sandbox runs stdlib-only scripts.