How to Install Python on EC2(AWS)

Introduction

Amazon EC2 (Elastic Compute Cloud) allows users to run virtual servers in the cloud, providing scalable computing capacity. If you're working with EC2 and need to install Python, this article will walk you through how to do it using PowerShell. Whether you're a cloud enthusiast, developer, or system administrator, you'll find this process simple and effective.

Prerequisites

Before you start, ensure you have the following.

  • AWS CLI installed and configured with appropriate credentials.
  • An EC2 instance running (Amazon Linux 2 or Ubuntu).
  • A key pair (.pem file) for SSH access to the EC2 instance.
  • PowerShell installed on your local machine.

Steps to Install Python on EC2 Using PowerShell

Step 1. Connect to Your EC2 Instance via PowerShell.

  • Open PowerShell on your local machine.
  • Use the following command to connect to your EC2 instance using SSH.
    ssh -i "your-key.pem" ec2-user@<your-ec2-public-ip>
    Instance connect

Step 2. Install Python.

Depending on your operating system, follow the appropriate command to install Python.

sudo apt install python3            

Python

Step 3. Verify the Installation.

After the installation, verify that Python and pip were successfully installed.

python3 --version

Version Check

Step 4. Check Running Python Processes.

To see if any Python 3 processes are running, use the ps command.

ps aux | grep python3

Running

This command will list all running processes related to python3, showing their status and process IDs.

Conclusion

Installing Python on an EC2 instance using PowerShell is straightforward, whether you choose to manually connect via SSH or automate the process with AWS Systems Manager. By following these steps, you'll be ready to deploy Python applications on your cloud-based infrastructure, taking full advantage of the scalability and flexibility of AWS EC2.


Similar Articles