pip & conda

pip & conda commands cheatsheet.

Install packages, pin versions and manage virtual environments in Python — the pip and conda commands you need.

pip — installing
pip install requestsInstall a package
pip install requests==2.31.0Install a specific version
pip install -r requirements.txtInstall everything in a requirements file
pip install -U requestsUpgrade a package to the latest
pip uninstall requestsRemove a package
pip — inspecting
pip listList installed packages
pip show requestsShow details about a package
pip freeze > requirements.txtSave exact versions to a file
pip install --user requestsInstall for your user only
Virtual environments
python -m venv venvCreate a virtual environment
source venv/bin/activateActivate it (macOS / Linux)
venv\\Scripts\\activateActivate it (Windows)
deactivateLeave the virtual environment
conda
conda create -n env python=3.11Create a named environment
conda activate envActivate an environment
conda install numpyInstall a package with conda
conda env listList your environments
conda env export > environment.ymlExport the environment to a file

Managing Python dependencies

Python projects pull in libraries with pip, the standard package installer. The everyday commands are pip install to add a package, pip install -r requirements.txt to set up a project from its dependency list, and pip freeze to record exact versions so others can reproduce your setup. Pinning versions and sharing a requirements file is what keeps a project working the same way on every machine.

Virtual environments matter

Installing packages globally leads to conflicts between projects, which is why virtual environments exist — isolated spaces where each project keeps its own dependencies. Create one with python -m venv venv and activate it, or use conda if you work in data science, where it manages both Python versions and non-Python libraries. Either way, activate the environment before installing, and your projects stay cleanly separated.

FAQ

Should I use pip or conda?
Use pip with venv for most general Python projects. conda is popular in data science because it manages Python versions and complex native dependencies (like those in scientific libraries) more smoothly.
How do I recreate someone's Python environment?
With pip, run pip install -r requirements.txt. With conda, run conda env create -f environment.yml. Both read a file listing the exact packages.

More cheatsheets