Error in upgrading pip on Linux

1.2k Views Asked by At

I am running the command on linux system as :

sudo pip install --upgrade pip

But I am getting the error message as :

pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application

Where as, if I go and check the pip --version, I get the response as :

pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

Why do I need 'pip==6.1.1' distribution and how do i get it ?

2

There are 2 best solutions below

0
On BEST ANSWER

On upgrading pip on thesystem, as the root user, you actually overwrite your system PIP program, and are subject to severe problem when further installing Python packages for your Linux system (with yum/dnf).

The correct way to work with this is to create a virtualenv as a user, and on that virtualenv you upgrade PIP. Isolated from the system Python installation. Anything remotely serious you will want to do with Python on this machine should be running at least Python 2.7 anyway - or 3.6 if it is Python 3 compatible. (Your system Python is 2.6 and you have a Python2. on /usr/local which might conflict, exactly depending on the order of PATH as you found out).

0
On

Ideally in case, pip should be upgraded by using sudo pip install --upgrade pip.

But since I am getting the error as : sudo: easy_install: command not found

I need to set environment variable path as below :

alias sudo='sudo env PATH=$PATH'

Once done, the upgrade command works normally.