If Python is still new to you, Python is a high-level programming language oriented towards objects that have become increasingly popular over the years. Python is commonly used in software, device management, analyzing scientific and numeric data, and much more.
It is possible to install either Python 2 or Python 3 on Ubuntu 20.04. With Ubuntu 20.04, though, Python 3 is the default version. PIP is a software tool that allows you to install different packages of Python on your device. Packages can be installed from the PyPI Python Package index repository and other index repositories into your framework with the PIP tool’s help.
It is strongly recommended to install the module’s dev package with the apt tool when installing a global Python module. They are checked to function correctly on Ubuntu systems. The prefix for Python 3 packages is python3- and the prefix for Python 2 packages is python2-.
Using Pip to globally install a module only if no deb package exists for that module.
You prefer to use pips only in a virtual world. For a particular project, Python Virtual Environments allows you to install Python modules in an isolated area rather than installed globally. This way, you do not have to worry about other Python projects being affected.
Installing Pip in Python 3
To install the Python 3 pip for Ubuntu 20.04, run the following root, or sudo user commands on your terminal:
sudo apt update sudo apt install python3-pip
All the dependencies needed to construct Python modules will also be installed with the above instruction.
Verify the installation when the installation is completed by reviewing the pip version:
Install a Python 2 pip
In the repositories of Ubuntu 20.04, Pip for Python 2 is not included. We’ll be using the get-pip.py script to build a pip for Python 2.
Sudo Add-apt-Universe Repository
Update the index for the packages and install Python 2:
sudo apt update sudo apt install python2
To download a get-pip.py script, use curl:
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
You can run the installing script as sudo user with python2 to install Pip for Python 2 once the repository is enabled:
sudo python2 get-pip.py
Pips can be installed worldwide. If it is just for your user to install, run the command without sudo. Setuptools and wheels are also installed in the script, enabling you to install source distributions.
Verify installation by the version number of the pip:
How do you make use of Pip?
Let’s see, a few useful simple commands for pips. With Pip, you can install PyPI, version control, local projects, and delivery file packages. Generally, PyPI packages are installed.
To display the list of all options and pip commands, type:
Using Pip <command> –help, you can get more information about a particular command. To get more information about the install order, for example, type:
pip3 install –help
Using Pip to install Packages
If you want to install a scrapy kit used to scrape data from websites and extract it.
You must run the following command to install the latest version of the package:
pip3 install scrapy
To install a particular version of the append == package, and the version number after the name of the package:
pip3 install scrapy==1.5
Download the requirements.txt packages:
Requirements.txt is a text file that includes a list of versions of the pip packages needed to run a particular Python project.
To install a list of requirements listed in a file, use the following command:
pip3 install -r requirements.txt
Installed Packages listing
Use the following command to list all the installed pip packages:
Upgrade with Pip a Kit
To update the kit that is already installed to the new version, enter:
pip3 install --upgrade package_name
Uninstalling Pip Packages
To uninstall a running package:
pip3 uninstall package_name
Here you have learned about installing pip on your Ubuntu operating system and using pips to handle Python packages.