Python — Pip Basic Commands

What is Pip? Pip is a tool for installing and managing Python packages. As well as Python, pip can be install on various operation systems: Linux, Mac, Windows, etc.

Install Pip


Install pip on MacOS, using easy_install command and upgrade pip to the latest version:

sudo easy_install pip
sudo pip install --upgrade pip


Install pip in Ubuntu, using apt-get package manager:

sudo apt-get update
sudo apt-get install python-pip
sudo pip install --upgrade pip


Install pip in CentOS from EPEL repository, using yum package manager:

sudo yum update
sudo yum install epel-release
sudo yum install python-pip
CentOS-7 and higher:
sudo pip install --upgrade pip
sudo pip install pip==9.0.3

Pip List

List installed packages:

pip freeze

Show version of the particular package:

pip freeze | grep <PACKAGE>

Search for a package:

pip search "<PACKAGE>"

List all available versions of a package:

pip install <PACKAGE>==

Pip Install

Install the latest version of a package:

pip install <PACKAGE>

Install the specific version of a package:

pip install <PACKAGE>==<VERSION>

Install packages from requirements.txt file:

pip install -r requirements.txt

Install local package:

pip install <DIRECTORY>

Install local package in editable mode:

pip install -e <DIRECTORY> The must have a file in it.

Pip Upgrade

Upgrade a package to the latest version:

pip install --upgrade <PACKAGE>

Upgrade/downgrade a package to the specific version:

pip install --upgrade <PACKAGE>==<VERSION>

Upgrade pip itself:

pip install --upgrade pip

Upgrade/downgrade pip itself to the specific version:

pip install --upgrade pip==<VERSION>

Pip Uninstall

Uninstall a package:

pip uninstall <PACKAGE>

Uninstall all packages:

pip freeze | xargs pip uninstall -y
{{ message }}

{{ 'Comments are closed.' | trans }}