Python PIP
pip is Python's package installer. It downloads from PyPI — the Python Package Index — into your environment.
Common commands
| Command | What it does |
|---|---|
pip install requests | Install the latest version. |
pip install 'django==5.0' | Pin a version. |
pip install -r requirements.txt | Install everything in the file. |
pip install -U pkg | Upgrade. |
pip uninstall pkg | Remove. |
pip list / pip freeze | What's installed. |
pip show pkg | Details of one package. |
requirements.txt
A plain text file listing your project's deps:
requirements.txt
requests==2.32.0 pydantic>=2.5 black
Freeze the exact versions installed:
SHELL
pip freeze > requirements.txt
Use a virtual environment
Don't install packages globally. Make a venv per project:
SHELL
python -m venv .venv source .venv/bin/activate # macOS / Linux .venv\Scripts\activate # Windows pip install requests
Beyond pip
| Tool | Why |
|---|---|
pipx | Install CLI apps into isolated venvs. |
uv | Rust-fast installer + venv manager (2024+). |
poetry / hatch / pdm | Project + dependency managers. |
conda | Heavier — also handles native libs (popular in science/ML). |
Tip: Pin everything in production with a lock file. Floating versions ship one day, break the next.
Example
Example
# In a shell, not in code:
# pip install requests
# Then in code:
# import requests; print(requests.get('https://httpbin.org/json').json())
print('See requests lesson for the runnable demo.')
Try it Yourself »
Exercise
Install a package.
pip
requests
Seven letters.
Discussion
Loading…