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 |
Time | N/A |
- 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.
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 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
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 --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) --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 horizon
References
- PyPI – the Python Package Index.
- Pip installer documentation and download from the official project site.
🐧 5 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
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
OMG – thankyou for that!
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…
:-)
Looks like you need to get the pip and setuptools .tar.gz files as well before you run “python virtualenv.py py_virtual”:
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?