The pip package manager provides a convenient way to install
Python packages. It is operating system independent so
can be used on a variety of operating systems, including
Linux,
OS X/macOS,
and
Microsoft Windows. You can determine if it is already installed on a Linux
or OS X system by issuing the command which pip at a
shell prompt.
$ which pip /usr/bin/which: no pip in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/lo cal/sbin:/usr/sbin:/home/jdoe/.local/bin:/home/jdoe/bin) $
If it isn't installed, but easy_install is installed, you
can use the easy_install Python script to install pip. If
easy_install isn't installed, you can install it on a
CentOS
Linux system by running yum install python-setuptools, since
it is part of the python-setuptools package, as shown below.
Setuptools
is a package development process library. The easy_install utility
is a short 10 line Python script, which provides a mechanism to install
Python programs and libraries in the the Python Eggs format.
$ which easy_install
/usr/bin/easy_install
$ rpm -qf /usr/bin/easy_install
python-setuptools-0.9.8-3.el7.noarch
$ rpm -qi python-setuptools
Name : python-setuptools
Version : 0.9.8
Release : 3.el7
Architecture: noarch
Install Date: Sun 05 Oct 2014 07:34:34 PM EDT
Group : Applications/System
Size : 2039798
License : Python or ZPLv2.0
Signature : RSA/SHA256, Fri 04 Jul 2014 12:41:51 AM EDT, Key ID 24c6a8a7f4a80eb5
Source RPM : python-setuptools-0.9.8-3.el7.src.rpm
Build Date : Mon 09 Jun 2014 07:36:55 PM EDT
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://pypi.python.org/pypi/setuptools
Summary : Easily build and distribute Python packages
Description :
Setuptools is a collection of enhancements to the Python distutils that allow
you to more easily build and distribute Python packages, especially ones that
have dependencies on other packages.
This package contains the runtime components of setuptools, necessary to
execute the software that requires pkg_resources.py.
This package contains the distribute fork of setuptools.
$ file $(which easy_install)
/usr/bin/easy_install: Python script, ASCII text executable
$ wc -l /usr/bin/easy_install
10 /usr/bin/easy_install
$ cat /usr/bin/easy_install
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.9.8','console_scripts','easy_install'
__requires__ = 'setuptools==0.9.8'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('setuptools==0.9.8', 'console_scripts', 'easy_install')()
)
$To install pip with easy_install, log into the
root account and issue the command easy_install pip, which
will install the the pip Python script in /usr/bin.
# easy_install pip Searching for pip Reading https://pypi.python.org/simple/pip/ Best match: pip 9.0.1 Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d 6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69 d63c9 Processing pip-9.0.1.tar.gz Writing /tmp/easy_install-LrtDFh/pip-9.0.1/setup.cfg Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-LrtDFh/pip- 9.0.1/egg-dist-tmp-2yNYuH /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution op tion: 'python_requires' warnings.warn(msg) warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching '.landscape.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'appveyor.yml' no previously-included directories found matching '.github' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Adding pip 9.0.1 to easy-install.pth file Installing pip script to /usr/bin Installing pip2.7 script to /usr/bin Installing pip2 script to /usr/bin Installed /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip # which pip /usr/bin/pip # file /usr/bin/pip /usr/bin/pip: Python script, ASCII text executable #
The installation will put a pip .egg file in
/usr/lib/python2.x/site-packages/pip-9.0.1-py2.7.egg
where the python2.x will reflect the version of Python you have
on the system (you can determine the version of Python on the system
with python --version). E.g., python2.7 in this
example.
Related articles: