Linux

How to Install Packages in Python on Linux?

To install a package in Python, we use pip, which is Python’s package manager. In this tutorial, we will discuss how to install packages in Python on a Linux system.

To install packages in Python on Linux, you must have Python and pip installed on your machine. Since Python usually comes pre-installed with Linux, you may need to manually install pip if you’re using Python 2.9 or below.

Installing PIP on Linux: To install pip, follow these methods:

Method 1: Using the apt install command: sudo apt install pip

Method 2: Using a Python script to install pip: Step 1: Visit the following website to download the script:

https://bootstrap.pypa.io/get-pip.py Alternatively, you can download the Python script to install pip by running this command:

wget https://bootstrap.pypa.io/get-pip.py

Step 2: Run the script using python

After installing pip, follow these steps to install a Python package:

Step 1: Visit the following website, search for the package you want to install, and press enter.

For example, we are going to search for pandas. A popular library to manipulate CSV files.

Step 2: Click on the package you want to install and copy the installation instructions.

Step 3: Open the terminal, paste the copied command, and press enter.

This will install the pandas package in Python on your Linux machine.

To uninstall a package, simply use the following command:

pip uninstall ‘package name’

Here, “package name” can be replaced with any other package name.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button