pip & Package Management
Install and manage Python packages with pip.
At the end of Python Essentials you got the map of pip and virtual environments. This module is where the map becomes muscle memory — by the end you'll set up projects exactly the way professionals do.
pip (Pip Installs Packages) downloads packages from PyPI — the Python Package Index, a public library of over 500,000 packages. Need to make HTTP calls?requests. Crunch data? pandas. Build a website? flask. Someone has already written, tested, and shared the hard part:
pip install requestsOne command, and import requests works in your code.
The commands you'll actually use, in rough order of frequency:
# Install the latest version of a package
pip install requests
# Install an EXACT version
pip install requests==2.31.0
# Upgrade a package you already have
pip install --upgrade requests
# List everything installed
pip list
# Details about one package (version, location, dependencies)
pip show requests
# Remove a package
pip uninstall requestsNo restart needed — the moment pip install finishes, the package is importable.
Which pip command installs a package?
- Apip get requests
- Bpip install requests
- Cpip add requests
- Dpip fetch requests
Why pin versions with ==? Because "latest" changes.
If you install flask today and a teammate installs flask next month, you may get different versions with different behavior — the classic "works on my machine" bug. Pinning makes installs reproducible:
pip install flask==3.0.0 # exact version
pip install "flask>=2.0,<4.0" # an acceptable rangeIn real projects, versions get pinned in a file (requirements.txt — two lessons from now) rather than typed by hand.
Pin the install to exactly version 2.31.0:
pip install requests___2.31.0You're debugging and need to know which version of requests is installed and where it lives. Which command?
- Apip info requests
- Bpip show requests
- Cpip version requests
- Dpip where requests