How to Install Packages in Python on Linux?
To install a package in python, we use pip. The pip is a python package manager. In this tutorial, we will be discussing how we can install packages in python on a Linux system.
To install packages in python on Linux, we must have python and pip installed on our Linux machine. As python comes preinstalled with the Linux system, we may have to install pip manually if we are using python 2.9 or below.
Installing PIP on Linux:
To install pip, follow the following methods:
Method 1: Using apt install command
sudo apt install pip
Method 2: Using python script to install pip
Step 1: Go through the following website and download the script.
Or using the following command, you can download the python script to install pip:
Step 2: Run the script using python
After installing pip, do the following steps to install a python package:
Step 1: Go through the following website and search for the package that you want to install and hit enter.
For example, we are going to search for pandas. A popular library to manipulate CSV files.
Step 2: Click on the package that you want to install and copy the installation instruction.
Step 3: Now open up the terminal and paste the above-copied command and hit enter.
This will install the pandas package in python on your Linux machine.
To uninstall a package simply use the following command:
pip uninstall pandas
Here, pandas can be replaced with any other package name.
Please Login to comment...