≡ Menu

Linux: Install pip Client To Install Python Packages

I would like to install python packages using the pip command which is an easy_install command replacement. How do I install pip comamnd under RHEL / CentOS / Debian / Ubuntu Linux server systems?

The pip command 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. pip is very useful for web development as well as for sys-admins who manages cloud computing based resources created Openstack, Rackspace, AWS, Google and other cloud computing service providers. The pip command can be installed in two different methods:

  1. Method #1: pip for all users with root privileges required. It is recommended that you use package manager to install the pip.
  2. Method #2: pip for a single user with no root privileges required. It is recommended that you use virtualenv script, which create isolated Python environments in your $HOME directory.
WARNING! Only use any one of the following method to install pip. Do not install pip using both methods.

Method #1: Install pip for all users

The pip command is not installed by default. You need to install it as per your distro.

RHEL / CentOS / Fedora Linux installation

First, turn on EPEL repo for RHEL / CentOS Linux. Next, type the following yum command under RHEL / CentOS / Fedora Linux to install python-pip package:
# yum -y install python-pip
Sample outputs:

Loaded plugins: product-id, refresh-packagekit, rhnplugin, security,
              : subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-pip.noarch 0:0.8-1.el6 will be installed
--> Processing Dependency: python-setuptools for package: python-pip-0.8-1.el6.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package             Arch     Version         Repository                   Size
 python-pip          noarch   0.8-1.el6       epel                        178 k
Installing for dependencies:
 python-setuptools   noarch   0.6.10-3.el6    rhel-x86_64-workstation-6   336 k
Transaction Summary
Install       2 Package(s)
Total download size: 513 k
Installed size: 764 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): python-pip-0.8-1.el6.noarch.rpm                   | 178 kB     00:01     
(2/2): python-setuptools-0.6.10-3.el6.noarch.rpm         | 336 kB     00:00     
Total                                            63 kB/s | 513 kB     00:08     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
 Userid : EPEL (6) <epel@fedoraproject.org>
 Package: epel-release-6-7.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : python-setuptools-0.6.10-3.el6.noarch                        1/2 
  Installing : python-pip-0.8-1.el6.noarch                                  2/2 
Installed products updated.
  Verifying  : python-setuptools-0.6.10-3.el6.noarch                        1/2 
  Verifying  : python-pip-0.8-1.el6.noarch                                  2/2 
  python-pip.noarch 0:0.8-1.el6                                                 
Dependency Installed:
  python-setuptools.noarch 0:0.6.10-3.el6                                       

Please note that name of the command is pyton-pip under RHEL and friends. I recommend that you add the following alias to your ~/.bashrc file, enter:

$ echo 'alias pip="/usr/bin/pip-python"' >> $HOME/.bashrc
$ . $HOME/.bashrc

Debian / Ubuntu Linux installation

Type the following apt-get command to install
# apt-get install python-pip
$ sudo apt-get install python-pip
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 67.8 kB of archives.
After this operation, 332 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main python-pip all 0.7.2-1 [67.8 kB]
Fetched 67.8 kB in 1s (40.4 kB/s)                     
Selecting previously deselected package python-pip.
(Reading database ... 274928 files and directories currently installed.)
Unpacking python-pip (from .../python-pip_0.7.2-1_all.deb) ...
Processing triggers for man-db ...
Setting up python-pip (0.7.2-1) ...
Processing triggers for python-support ...

Method #2: Install pip for a single user

This method does not require root access or modify your system Python installation. Type the following command:

curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py

Sample outputs:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  107k  100  107k    0     0  35120      0  0:00:03  0:00:03 --:--:-- 49618

Create your own virtual environment called py_virtual:

python virtualenv.py py_virtual

Sample outputs:

New python executable in py_virtual/bin/python
Installing setuptools............................done.
Installing pip.....................done.

Activate your new virtual environment, run:

. py_virtual/bin/activate

Sample outputs (note prompt changed):


How do I use pip command?

To install new python package type:

pip install packageName

To uninstall python package installed by pip type:

pip uninstall packageName

To search python package type:

pip search packageName

To see a list of all commands type:

pip help

Sample outputs

 --version                    show program's version number and exit
 -h, --help                   Show help
 -v, --verbose                Give more output
 -q, --quiet                  Give less output
 --log              Log file where a complete (maximum verbosity) record will be kept
 --proxy               Specify a proxy in the form user:passwd@proxy.server:port. Note that the user:password@ is optional and required only if you
                              are behind an authenticated proxy. If you provide user@proxy.server:port then you will be prompted for a password.
 --timeout           Set the socket timeout (default 15 seconds)
                              Default action when a path already exists. Use this option more than one time to specify another action if a certain option is
                              not available. Choices: (s)witch, (i)gnore, (w)ipe, (b)ackup

Commands available:
  bundle: Create pybundles (archives containing multiple packages)
  freeze: Output all currently installed packages (exact versions) to stdout
  help: Show available commands
  install: Install packages
  search: Search PyPI
  uninstall: Uninstall packages
  unzip: Unzip individual packages
  zip: Zip individual packages


Search all openstack cloud releated tools:

pip search openstack

Sample outputs:

ftp-cloudfs               - FTP interface to Rackspace Cloud Files and OpenStack Swift
vaporize                  - A clean and consistent library for the Rackspace Cloud / OpenStack
openstack.nose_plugin     - openstack run_tests.py style output for nosetests
nova-adminclient          - client for administering OpenStack Nova
python-glanceclient       - Client library for OpenStack Image API
python-novaclient         - Client library for OpenStack Nova API.
python-quantumclient      - CLI and python client library for OpenStack Quantum
python-melangeclient      - Client library for OpenStack Melange API.
txAWS                     - Async library for EC2, OpenStack, and Eucalyptus
python-swiftclient        - Client Library for OpenStack Object Storage API
python-keystoneclient     - Client library for OpenStack Keystone API
django_openstack_auth     - A Django authentication backend for use with the OpenStack Keystone Identity backend.
python-cinderclient       - Client library for OpenStack Cinder API.
rackspace-auth-openstack  - Rackspace Auth Plugin for OpenStack Clients.
openstackocci             - OCCI interface for Openstack.
django-openstack          - A Django interface for OpenStack.
futuregrid_passwdstack    - Password Stack is a simple tool that allows normal users to reset their own password in the OpenStack Dashboard
cloudenvy                 - Fast provisioning on openstack clouds.
reddwarf                  - PaaS services for Openstack
python-openstackclient    - OpenStack command-line client
reviewday                 - Report generator for OpenStack code reviews.
horizon                   - The OpenStack Dashboard.
hpcloud-auth-openstack    - HP Cloud Auth Plugin for OpenStack Clients.

To install the OpenStack dashboard package called horizon, enter:

pip install horizon
  • PyPI – the Python Package Index.
  • Pip installer documentation and download from the official project site.
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 5 comments… add one }
  • Some Guy March 13, 2013, 2:11 am

    The command in CentOS/RHEL is pip-python not python-pip as you have listed. Just FYI for anyone in the future that might read this

    • gareth January 29, 2014, 6:07 pm

      OMG – thankyou for that!

    • Majickmann July 13, 2015, 8:07 pm

      Actually… both pip-python AND python-pip are aliases for pip:
      -rwxr-xr-x 1 root root 281 Jul 16 2013 /usr/bin/pip
      lrwxrwxrwx 1 root root 3 Jul 9 14:49 /usr/bin/pip-python -> pip
      lrwxrwxrwx 1 root root 3 Jul 9 14:49 /usr/bin/python-pip -> pip

      Hope this helps…

  • Karl September 9, 2013, 11:08 am

    Looks like you need to get the pip and setuptools .tar.gz files as well before you run “python virtualenv.py py_virtual”:

    curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv_support/pip-1.4.1.tar.gz
    curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv_support/setuptools-0.9.8.tar.gz
  • Rayhon November 29, 2013, 3:54 am

    Hi, i entered the first command of method two “curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py” on my fedora PC, but I didn’t continue that method instead I installed it using “sudo yum install python-pip” which I got from the pip website. Do I need to undo anything I did?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , ,