Installing Python and pip on Ubuntu

Python is a popular programming language, and pip is the package manager for Python. In this guide, we'll show you how to install Python and pip on Ubuntu so you can start developing with Python.

← Back

Step 1: Update Your System

Before installing Python, it's a good idea to update the package list to ensure you're installing the latest available version. Run the following command:

sudo apt update

Step 2: Install Python

Ubuntu usually comes with Python preinstalled, but it might not be the version you want. To install Python 3 (which is the recommended version), run the following command:

sudo apt install python3

Step 3: Verify Python Installation

To verify that Python is installed correctly, check the version by running:

python3 --version

This command should display the Python version installed, such as Python 3.x.x.

Step 4: Install pip

pip is the package installer for Python, and you can use it to install additional Python libraries. To install pip for Python 3, run the following command:

sudo apt install python3-pip

Step 5: Verify pip Installation

Once pip is installed, you can verify it by checking the version:

pip3 --version

This should output the version of pip installed, such as pip 21.x.x from ....

Step 6: Upgrading pip (Optional)

If you want to upgrade pip to the latest version, you can run the following command:

sudo python3 -m pip install --upgrade pip

Step 7: Install Python Packages Using pip

Now that pip is installed, you can start installing Python packages. For example, to install the popular requests library, run the following command:

sudo pip3 install requests

Conclusion

You've successfully installed Python and pip on your Ubuntu system! You can now start using Python for development and installing libraries using pip. Make sure to keep your Python and pip versions updated for security and performance improvements.

← Back