pip(1)
pip is the package installer for Python, used to install and manage Python packages from PyPI and other indexes.
Synopsis
pip [OPTIONS] COMMAND [ARGS]...Description
pip is the primary tool for installing Python packages and their dependencies. It downloads packages from the Python Package Index (PyPI) by default, but can also install from local files, git repositories, and custom indexes. pip manages package versions, handles dependencies automatically, and can create reproducible environments with requirements files.
Common workflows include installing single packages (pip install package-name), listing installed packages (pip list), and using requirements.txt files to manage project dependencies (pip install -r requirements.txt). pip can upgrade packages, uninstall them, and freeze the current environment state for reproducibility.
Common options
| Flag | What it does |
|---|---|
install | install packages or upgrade existing ones |
-r, --requirement FILE | install all packages listed in a requirements file |
-U, --upgrade | upgrade packages to the newest available version |
--user | install packages in user home directory instead of system-wide |
-e, --editable PATH | install in editable/development mode from local path or git URL |
list | list installed packages and their versions |
freeze | output installed packages in requirements format for reproducibility |
uninstall | remove one or more packages |
-y, --yes | assume yes to all prompts (e.g., when uninstalling) |
--index-url URL | base URL of Python Package Index (default: https://pypi.org/simple) |
--no-cache-dir | disable pip cache to save disk space or force fresh downloads |
Examples
install the requests library from PyPI
pip install requestsinstall all packages listed in requirements.txt, respecting version constraints
pip install -r requirements.txtupgrade an already-installed package to its newest version
pip install -U requestsshow all installed packages and their versions
pip listsave current environment's packages and exact versions to requirements.txt
pip freeze > requirements.txtinstall directly from a git repository in editable mode for development
pip install -e git+https://github.com/user/repo.git#egg=packageremove the numpy package without prompting for confirmation
pip uninstall -y numpyinstall flask in the user's local directory instead of system-wide
pip install --user flask