How to Upgrade PIP

If you are a Python coder. It is almost 100% that you would be using pip to install packages.

How To Upgrade pip On Linux

Lets see how we can upgrade pip on Linux first.

Lets check the pip version.

In [3]:
pip --version
pip 9.0.1 from /home/anaconda3/lib/python3.7/site-packages (python 3.7)

Lets try installing a python package. example pip install python-levenshtein

In [5]:
pip install python-levenshtein

I got following warning

You are using pip version 9.0.1, however version 19.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

We can also find the latest available version using following command.

In [11]:
pip search pip | egrep pip | egrep -i pypa
pip (19.3.1)                          - The PyPA recommended tool for installing Python packages.
You are using pip version 9.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

To install the version we can either run the command pip install --upgrade pip or do pip install pip==19.3.1

Lets try first pip install --upgrade pip first

In [12]:
pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
  Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 1.1MB/s eta 0:00:01
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-19.3.1
In [13]:
pip --version
pip 19.3.1 from /home/anaconda3/lib/python3.7/site-packages/pip (python 3.7)

Lets try now pip install pip==19.3.1

In [14]:
pip install pip==19.3.1
Requirement already satisfied: pip==19.3.1 in /home/anaconda3/lib/python3.7/site-packages (19.3.1)

How To Upgrade Pip In Windows.

If you have Cygwin installed. Then the above commands for Linux should work on Cygwin too.

Otherwise first check the pip version. Use python -m for every command

In [15]:
python -m pip --version

To install specific version

In [16]:
python -m pip install pip==19.3.1

Or use following command

In [17]:
python -m pip install --upgrade pip

Related Topics: