Pip is a platform independent package management software. Pip stands for “Pip Installs Packages”. The Python Packaging Authority (PyPA) maintains many of the python relevant projects. The software developed through the PyPA is used to package, share, and install Python software and to interact with indexes of downloadable Python software such as PyPI, the Python Package Index. In PyPI, anyone can easily Find, install and publish Python packages with the Python Package Index. PyPI shares more than 1,81,983 projects around the world.
Environment:
- RHEL 7 / CentOS 7
- pip2 – For python 2 package management
- pip3 – For Python 3 package management
Install and configure Pip2 on RHEL 7 / CentOS 7
1. Login to RHEl 7 / CentOS 7 as the root user.
2. Ensure that your system has internet access to pull the pip binary.
3. Download pip using curl command.
[root@ansible-server ~]# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1669k 100 1669k 0 0 269k 0 0:00:06 0:00:06 --:--:-- 325k [root@ansible-server ~]#
If you received the following SSL certificate error, use “–insercure” flag
curl performs SSL certificate verification by default, using a “bundle” of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn’t adequate, you can specify an alternate file using the –cacert option.
If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you’d like to turn off curl’s verification of the certificate, use
the -k (or –insecure) option.
[root@ansible-server ~]# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py --insecure % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1669k 100 1669k 0 0 269k 0 0:00:06 0:00:06 --:--:-- 325k [root@ansible-server ~]#
Cautious: “get-pip.py” does not coordinate with OS native package manager.
4. Install pip using python. It will install pip2 if the default python version is 2.x.
[root@ansible-server ~]# python get-pip.py Collecting pip Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB) |████████████████████████████████| 1.4MB 269kB/s Installing collected packages: pip Found existing installation: pip 19.0.3 Uninstalling pip-19.0.3: Successfully uninstalled pip-19.0.3 Successfully installed pip-19.1.1 [root@ansible-server ~]# pip --version pip 19.1.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) [root@ansible-server ~]#
If you get an SSL certificate error, use the following command as a workaround.
[root@ansible-server ~]# python get-pip.py --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org
How to Install pip3 on RHEL 7 / CentOS 7: (Can co-exists with pip2)
1. Download “get-pip.py” . (Refer Step 3 – Pip2 )
[root@ansible-server ~]# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. Locate python 3.x binary.
[root@ansible-server ~]# which python3 /usr/bin/python3 [root@ansible-server ~]# [root@ansible-server ~]# file /usr/bin/python3 /usr/bin/python3: symbolic link to `python3.4' [root@ansible-server ~]# file /usr/bin/python3.4 /usr/bin/python3.4: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=66ec5b393626018f73af659b45745b161263fee9, stripped [root@ansible-server ~]#
3. Run the following command to install pip3 on your system.
[root@ansible-server ~]# /usr/bin/python3 get-pip.py Collecting pip Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB) |████████████████████████████████| 1.4MB 293kB/s Collecting wheel Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl Installing collected packages: pip, wheel Successfully installed pip-19.1.1 wheel-0.33.4
4. verify the pip version.
[root@ansible-server ~]# pip --version pip 19.1.1 from /usr/lib/python3.4/site-packages/pip (python 3.4) [root@ansible-server ~]#
5. pip2 can be still accessed using pip2 command.
[root@ansible-server ~]# pip2 --version pip 19.1.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) [root@ansible-server ~]#
6. You could simply replace the default (/usr/bin/pip) pip with the required version of pip binary.
[root@ansible-server ~]# ls -lrt /usr/bin/pip -rwxr-xr-x 1 root root 215 Mar 13 02:02 /usr/bin/pip [root@ansible-server ~]# ls -lrt /usr/bin/pip3 -rwxr-xr-x 1 root root 215 Mar 13 02:02 /usr/bin/pip3 [root@ansible-server ~]# ls -lrt /usr/bin/pip2 -rwxr-xr-x 1 root root 214 Mar 13 01:57 /usr/bin/pip2 [root@ansible-server ~]#
We have successfully installed pip2 and pip3. Hope this article is informative to you.
ges says
Thanks, only way actually worked!
Tu Nguyen says
How to install python 3 on RHEL 7? I can’t find python3 to install pip3