Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 971
evsmith Avatar asked Jul 08 '16 13:07

evsmith


People also ask

How do I update pip to latest version?

Updating Pip b is available.” You can run “pip install --upgrade pip” to install and use the new version of pip. To update pip2 or pip3 using this command, only replace the first pip with the pip version.

Should I upgrade my pip version?

Whether you're setting up a development environment or writing your Dockerfile , make sure you upgrade pip . Otherwise you'll have a much harder time installing packages.

How do I update pip in Jupyter notebook?

Use pip install notebook --upgrade or conda upgrade notebook to upgrade to the latest release. We strongly recommend that you upgrade to version 9+ of pip before upgrading notebook . Use pip install pip --upgrade to upgrade pip.


1 Answers

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
like image 149
edwinksl Avatar answered Sep 21 '22 09:09

edwinksl