Skip to main content

Understanding pip

pip installs distribution packages, usually from the Python Package Index (PyPI). A distribution's project name is not always identical to the name imported in Python. pip does not install Python itself and is not a general environment manager.

Address the intended interpreter​

Prefer module invocation over a bare pip command:

python -m pip --version
python -m pip install "pandas>=2,<3"

On Windows outside an activated environment, py -m pip is also common. On macOS/Linux outside an environment, the interpreter may be named python3. The version output includes the pip location and Python version; confirm both before changing an environment.

Common commands​

python -m pip list
python -m pip show pandas
python -m pip check
python -m pip uninstall pandas

pip check reports incompatible or missing installed dependencies. It does not prove that an application behaves correctly; run the project's tests as well.

Version specifiers​

python -m pip install "SomeProject==1.4.2"
python -m pip install "SomeProject>=1.4,<2"
python -m pip install "SomeProject~=1.4.2"

Quote specifiers containing shell operators such as < or > so the shell does not interpret them as redirections.

If pip is missing​

Official Python installers normally provide pip, and venv bootstraps it by default. First try the standard-library bootstrap for the intended interpreter:

python -m ensurepip --upgrade

If the interpreter is managed by a Linux distribution or another package manager, follow that distributor's instructions instead of running downloaded bootstrap scripts or writing into the system environment.