PIP is a package management system used for installation and management of software packages in Python. PIP stands for Python Package Index (PyPI). Installation of PIP is pretty straightforward. In this tutorial, described how to install PIP on Ubuntu 18.04 system.
Before you start installation of PIP, you should logged in as non-root user with sudo privileges.
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.
At first, you should update the package list using below command:
sudo apt update
Next, execute below command to install pip:
sudo apt install python3-pip
Once the installation is finished you can verify installation by typing:
Version number of PIP may change with time. It will show output as below:
Output pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
Installing pip for Python 2
First of all you need 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
Again, confirm the version of pip by typing:
Output should as:
Output pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Use of PIP for Python 3
Here, we will see some useful basic pip commands. First of all to get the list of all the commands in PIP issue below command:
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.
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.
Install Packages Using Requirements File
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
Upgrade a Package With Pip
You can upgrade already installed packages to latest version using below command:
pip3 install --upgrade PACKAGE_NAME
Uninstalling Packages With Pip
To uninstall package with pip issue command:
pip3 uninstall PACKAGE_NAME
Note : If you are using
Python 2 then replace
pip when issuing commands.
You have learned how to install PIP on Ubuntu 18.04 for Python 3 and Python 2. Also you learnt how to manage Python packages using pip. You can get more details about pip from this guide.
If you have any question or suggestion leave a comment below.
Leave a Reply