iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Python PIP

pip is Python's package installer. It downloads from PyPI — the Python Package Index — into your environment.

Common commands

CommandWhat it does
pip install requestsInstall the latest version.
pip install 'django==5.0'Pin a version.
pip install -r requirements.txtInstall everything in the file.
pip install -U pkgUpgrade.
pip uninstall pkgRemove.
pip list / pip freezeWhat's installed.
pip show pkgDetails 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

ToolWhy
pipxInstall CLI apps into isolated venvs.
uvRust-fast installer + venv manager (2024+).
poetry / hatch / pdmProject + dependency managers.
condaHeavier — 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

Test yourself

Q1. pip installs packages from…
Q2. requirements.txt is consumed by…
Q3. For project isolation use…

Discussion

Loading…