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?
| Tutorial details | |
|---|---|
| Difficulty | Intermediate (rss) |
| Root privileges | Yes / No |
| Requirements | Python, gcc, python developer tools |
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:
- Method #1: pip for all users with root privileges required. It is recommended that you use package manager to install the pip.
- 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
================================================================================
Installing:
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
Installed:
python-pip.noarch 0:0.8-1.el6
Dependency Installed:
python-setuptools.noarch 0:0.6.10-3.el6
Complete!
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
OR
$ 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: python-pip 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):
(py_virtual)vivek@wks01:~$
How do I use pip command?
To install new python package type:
pip install packageNameTo 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 helpSample outputs
Usage: pip COMMAND [OPTIONS] --version show program's version number and exit -h, --help Show help -v, --verbose Give more output -q, --quiet Give less output --logLog 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) --exists-action 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
Examples
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 horizonReferences
- PyPI - the Python Package Index.
- Pip installer documentation and download from the official project site.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop




![Rackspace Cloud Files: Upload Files Using Secure FTP (SFTP) Client [ sftp-cloudfs ]](http://s0.cyberciti.org/uploads/faq/2013/02/rackspace-cloud-files-cdn-url-150x150.jpg)








{ 1 comment… read it below or add one }
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