How should I upgrade pip on Ubuntu 14.04?
Solution 1
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
Solution 2
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
Related videos on Youtube
evsmith
Updated on September 15, 2022Comments
-
evsmith over 1 year
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?
-
Andrew almost 7 yearsTry not using
apt install python-virtualenv
. Instead, install it usingpip install virtualenv
using your system pip. The Ubuntu virtualenv package is way out of date, and will not work as expected on many newer packages. A newer virtualenv will give you a newer pip/wheel/setuptools, since it comes with those packaged inside it. If you ever want your venvs to be up-to-date by default, use your system pip to install virtualenv.