evsmith
evsmith

Reputation: 505

How should I upgrade pip on Ubuntu 14.04?

I want to get the most recent version (8.1.2) of pip. I'm using Ubuntu 14.04 and python 2.7.6. The version of pip in the Ubuntu repositories is only 1.5.4 (and can't install things like numpy). How are you actually meant to upgrade pip? I've discovered a few ways; maybe they're all equivalent but it would be good to know for sure.

Option 1: Upgrade pip with pip and change the link

apt-get install python-pip
pip install --upgrade pip
pip --version  # still shows 1.5.4
ln -s /usr/local/bin/pip /usr/bin/
pip --version  # 8.1.2, success!

Option 1a: Like above, but use python -m pip

pip install --upgrade pip
pip --version  # still shows 1.5.4
python -m pip --version  # 8.1.2, success!

Option 2: easy_install

easy_install -U pip
pip --version  # 8.1.2, success!

Option 3: Use a virtualenv (I know virtualenvs are awesome but I'm doing the installing in a docker container, so I was just going to install things globally).

virtualenv test123
source test123/bin/activate
pip --version  # pip 8.1.2 from ~/test123/local/lib/python2.7/site-packages

Option 4: The pip website suggests using their get-pip.py script, but also says this might leave the Ubuntu package manager in an inconsistent state.

Option 5: Upgrade Python: "pip is already installed if you're using Python 2 >=2.7.9", but this seems like overkill.

Is one of these the preferred method? Is there a better way I haven't found? Am I overthinking this?

Upvotes: 6

Views: 19487

Answers (3)

Rajen K Bhagat
Rajen K Bhagat

Reputation: 232

you can use following cammands

python -m pip install --upgrade pip

Upvotes: 0

Stryker
Stryker

Reputation: 6120

Depending on the operating system you are using the steps differ somewhat:

On ubuntu you can do the following:

sudo apt install python3-pip

sudo pip3 install --upgrade pip setuptools

sudo apt update&& sudo apt upgrade python-pip

On windows:

c:\>pip install --upgrade pip setuptools

On Osx:

 sudo pip3 install --upgrade pip setuptools

Upvotes: 3

edwinksl
edwinksl

Reputation: 7093

The most painless way that I found that works is to use install virtualenv and use pip inside a virtualenv. This does not even require you install pip at the system level (which you might have done by running sudo apt-get install python-pip):

sudo apt-get install python-virtualenv  # install virtualenv
virtualenv venv  # create a virtualenv named venv
source venv/bin/activate  # activate virtualenv
pip install -U pip  # upgrade pip inside virtualenv

Upvotes: 5

Related Questions