PIP is a package management system used for installation and management of software packages in Python. PIP stands for Python Package Index (PyPI).
In this context, we shall look into how to install PIP on Ubuntu 18.04 system. Before you start installation of PIP, you should logged in as root user with sudo privileges.
How to Install PIP for Python 3 ?
By default, Python 3 is pre-installed with Ubuntu 18.04. Follow the below steps to install PIP for Python 3.
i. Begin by updating the system package list using below command:
$ sudo apt update
ii. Next, execute below command to install pip:
$ sudo apt install python3-pip
iii. Once the installation is finished you can verify installation by typing:
$ pip3 --version
Note that the Version number of PIP may change with time.
How to Install pip for Python 2 ?
To begin with this installation procedure, ensure that the system is up to date. In order to update the package manager index by issue below command:
$ sudo apt update
After that you need to install Python 2 as it's not pre-installed. So run following command to install Python 2 and PIP for it:
$ sudo apt install python-pip
After Installation is completed, you can confirm the version of pip by running the below command:
$ pip --version
How to use PIP for Python 3 ?
In this section, we will see some useful basic pip commands. First of all to get the list of all the commands in PIP issue below command:
$ pip3 --help
If you want to get information for particular command then issue command as below:
$ pip install --help
Above command will give details about install command.
To search package using PIP just type as below:
$ pip3 search PACKAGE_NAME
You should replace PACKAGE_NAME with the name of package which you want to search.
How to Install Package Using Pip ?
Below is the syntax to install package with PIP:
$ pip3 install PACKAGE_NAME
Same as search replace the PACKAGE_NAME with package name.
How to Install Packages Using Requirements File with Pip ?
You can install packages using requirements file. requirement.txt is a text file that contains a list of pip packages with their versions which are required to run a specific Python project. Use below command to install a list of requirements specified in a file:
$ pip3 install -r requirements.txt
How to Upgrade a Package With Pip ?
You can upgrade already installed packages to latest version using below command:
$ pip3 install --upgrade PACKAGE_NAME
How to Uninstall Packages With Pip ?
To uninstall package with pip issue the below command:
$ pip3 uninstall PACKAGE_NAME
Note : If you are using Python 2 then replace pip3 with pip when issuing commands.