Easily install Python 3 and Pip on an EC2 Instance

In this article, you’ll discover how to install Python 3 and pip on an Amazon EC2 instance. Whether you’re working with Amazon Linux 2 or Ubuntu, we’ve got you covered.

Python is a versatile programming language, and pip is a package manager that makes managing Python packages a breeze.

In a nutshell, to install Python and Pip on Amazon Linux 2, run sudo yum update -y and yum install python3 -y.

To install Python and Pip on Ubuntu on an EC2 instance, run sudo apt update and sudo apt install python3 python3-pip -y.

Let’s dive into the step-by-step guide to get Python 3 and pip up and running on your EC2 instance.

1. Launch and Connect to Your Amazon EC2 Instance

Before you can install Python and pip, you’ll need to launch and connect to your EC2 instance.

Here’s how:

  1. Launch an EC2 Instance: Choose an Amazon Machine Image (AMI) based on Amazon Linux 2 or Ubuntu, depending on your preference.
  2. Connect to Your Instance: You can connect using the AWS Management Console or the AWS CLI. If you need assistance, refer to our previous article on securely connecting to an EC2 instance using AWS Session Manager.

1.1 Install Python 3 and pip on Amazon Linux 2

If you’re using Amazon Linux 2, follow these steps:

  1. Update the Package List: Run sudo yum update -y to ensure that all existing packages are up to date.
  2. Install Python 3: Execute sudo yum install python3 -y to install Python 3.
  3. Install pip: Python 3 on Amazon Linux 2 comes with pip, so no separate installation is needed.

1.2 Install Python 3 and pip on Ubuntu

For those using Ubuntu, the process is slightly different:

  1. Update the Package List: Run sudo apt update to update the package list.
  2. Install Python 3: Execute sudo apt install python3 to install Python 3.
  3. Install pip: Run sudo apt install python3-pip to install pip for Python 3.

2. Check Python and Pip version

After installation, it’s a good practice to verify the versions of Python and pip:

  1. Check Python Version: Run python3 --version to display the installed Python version.
  2. Check pip Version: Execute pip3 --version to display the installed pip version.

These commands will confirm that Python 3 and pip are installed correctly and ready for use.


Installing Python 3 and pip on an Amazon EC2 instance is a straightforward process, whether you’re using Amazon Linux 2 or Ubuntu.

By following the steps outlined in this article, you’ll have the tools you need to develop and manage Python applications on your EC2 instance.

Remember, Python is a powerful language with a rich ecosystem, and pip makes managing packages simple and efficient.

Danny Steenman

A Senior AWS Cloud Engineer with over 9 years of experience migrating workloads from on-premises to AWS Cloud.

I have helped companies of all sizes shape their cloud adoption strategies, optimizing operational efficiency, reducing costs, and improving organizational agility.

Connect with me today to discuss your cloud aspirations, and let’s work together to transform your business by leveraging the power of AWS Cloud.

I need help with..
stacked cubes
Improving or managing my CDK App.Maximize the potential of your AWS CDK app by leveraging the expertise of a seasoned CDK professional.
Reducing AWS Costs.We can start by doing a thorough assessment of your current AWS infrastructure, identifying areas with potential for cost reduction and efficiency improvement.
Verifying if my infrastructure is reliable and efficient.We’ve created a comprehensive AWS Operations Checklist that you can utilize to quickly verify if your AWS Resources are set up reliably and efficiently.