How to install pip on Ubuntu 12.04 LTS
May 9th, 2012

pip is a tool for installing and managing Python packages, such as those found in the Python Package Index. It’s a replacement for easy_install.

By default, Ubuntu 12.04 LTS doesn’t come with pip installed.

There are 2 alternative ways to get pip installed.

1) Installation through Ubuntu Software Center

Open Ubuntu Software Center and search for `easy_install` (without quotes)

Screenshot of Ubuntu 12.04 LTS Software Center

Highlight alternative Python package installer (python-pip) from the list and click Install

Screenshot of Ubuntu 12.04 LTS Software Center

Open terminal by pressing CTRL+ALT+T and type the following command:

which pip

and press Enter to verify that pip has been installed successfully.
The response should look something like this:

/usr/local/bin/pip

Done!

2) This approach assumes that you have Python 2.6 or older installed.
To verify issue the following terminal command:

python

The response to this command should look like:

Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

To exit Python shell type:

quit()

and press Enter

Open terminal by pressing CTRL+ALT+T and type the following:

cd ~

to navigate to your home directory.
Then issue the below command:

wget -P Downloads/ http://python-distribute.org/distribute_setup.py

Next step is to run the downloaded script.
To do this, issue this command:

sudo python Downloads/distribute_setup.py

and type your user password when prompted (Please, note that your account needs to be a member of Administrators group in order to issue sudo).
Hit Enter and let the script run.

To ensure easy_install is installed, issue the command below:

which easy_install

The typical response in case the installation completed successfully would look something like this:

/usr/local/bin/easy_install

The next thing to do is use easy_install to install pip. For that you’ll need to issue:

sudo easy_install pip

Enter your password if prompted to confirm command.
Let the installer run and once the installation is completed type:

which pip

This command should typically respond with something like this:

/usr/local/bin/pip

It’s done. You can use pip now to install python packages.
Here’s the example of usage.

pip install sqlalchemy

This command will try installing a python package called sqlalchemy.
For more information on how to use pip and the documentation please visit pip-installer.org

No Comments
Leave a Reply
You must be logged in to post a comment.