Python PIP is a package manager for software packages written in Python. PIP allows you to easily add and update software packages from Python Package Index. Python PIP is not installed on these operating systems by default. So, In this guide, we will see how to install Python PIP on Ubuntu and CentOS servers. It is a command line utility, It means that we will also learn a few basic commands to install, upgrade and uninstall software packages using PIP.
First of all, Let us get started with the installation of Python PIP in Ubuntu Operating system. There are some prerequisites that you have to complete before you can start following the commands. You must have sudo privilege on the server. Installation of new software packages requires sudo privilege.
So, If you have a sudo privilege, You can start following the guide based on the operating system you are using.
Install PIP on Ubuntu
First of all, We have to check the current version of python on our server. To check the current version of python, execute the following command on your server.
$ python -V
You will get the version number as output. Now, There are two possibilities. If you are using Ubuntu 16.04, You might have Python 2.* installed on your server. In case of Ubuntu 18.04, you might have Python 3.*.
INSTALL PIP FOR PYTHON 2
Now, If you have Python 2.7 installed on your server, execute the following commands to install Python PIP on your Ubuntu server.
$ sudo apt-get update $ sudo apt-get install python-pip -y
The first command will update the repositories on our server. And the second command will install Python PIP along with all the dependencies required to build python modules. Once the installation is complete, you can verify it by checking the version of PIP on your server.
To check the current version of PIP on your server, execute the following command.
$ pip -V
The output of the command will look like the following.
Output: pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
So, this is how you can install Python PIP if you have Python 2 on your Ubuntu server. Now let us see how to install PIP for Python 3.
INSTALL PIP FOR PYTHON 3
The process to install PIP for Python 3 is very similar to the installation for Python 2. There is the a tiny difference in one command. To install PIP for Python 3, execute the following commands on your server.
$ sudo apt-get update $ sudo apt-get install python3-pip -y
The -y
flag we are using here will suppress the confirmation prompt while installation. Once the process is complete, execute the following command to verify the PIP version installed on your server.
$ pip3 -V
The output of this command will be similar to the output given in case of Python 2, except the version number. So, this is how you can install Python PIP on Ubuntu Server. Now, Let us see how to do that on CentOS.
Install PIP on CentOS
In case of CentOS, you cannot install PIP as easily as we did on Ubuntu. It is because PIP is not available in default CentOS repositories. We have to add EPEL repository to our CentOS server to install PIP.
So, To add EPEL repository on our CentOS server, execute the following command.
$ sudo yum install epel-release
It will only take a few seconds to install. Once it is done, we can install PIP just like we did in Ubuntu. Execute the following command on your server to start the installation of PIP.
$ sudo yum install python-pip
Once the installation is complete, verify the installation by checking the version of PIP on your server. To check the current version of PIP, execute the following command on your server.
$ pip -V
Now, in case of CentOS, we also have to install Development tools required to build Python modules. Execute the following commands to install Development tools.
$ sudo yum install python-devel $ sudo yum groupinstall 'development tools'
It might take several minutes to install development tools on your machine. Once it is done, you can start using PIP on your CentOS server.
So, this is how you can install PIP on CentOS server. Now, Let us take a look at some common PIP commands.
How to use PIP
In this section of the guide, I will show you some basic commands for PIP so that you can get started with PIP fast. First of all, Let us see how to install a new software package using PIP.
$ pip install numpy
Here, numpy
is a popular python library. You can replace it with any other software package you want to install. Similarly, if you want to uninstall a specific package, you can run the following command.
$ pip uninstall numpy
Now, to get a complete list of all the packages installed on your server, execute the following command.
$ pip list
This command will give you the full list of packages installed on your server. However, you can use the --outdated
option to get list of all the outdated packages on the server, just like this.
$ pip list --outdated
From the list of all the outdated packages, if you want to upgrade any package to the newer version, you can use the following command.
$ pip install --upgrade numpy
So, this is how you can use PIP to manage Python software packages on your server.
TIP: Before installing any python module, check if it is available on the Linux distribution you are using. If it is available, install it using
apt
oryum
. It is because the python modules available in the distribution are tested and are reliable.
If you want to learn more PIP commands, execute the following command on your server.
$ pip --help
It will show you all the commands available with PIP as well as all the options you can use to control the execution of the command.
Conclusion: PIP is a very useful software package management system. It allows us to easily install, upgrade and uninstall python software packages on our server. It also allows us to search for the package by name in Python Package Index (Execute the pip --help
) command to learn more about it. Also, it is very easy to learn and is efficient.
Let us know in the comment section if you need our help to install PIP on your server. We will respond as soon as possible with the answer or solution to your question or issue. If you are an FastyCloud customer, please contact our Support staff to resolve your query quickly.