Open In App

How to Install Python 2.8 on AWS EC2?

Last Updated : 31 Oct, 2023
Like Article

AWS or Amazon Web Services is one of the biggest cloud services providers with a variety of services such as on-demand computational services, databases, storage space, etc. EC2 or Elastic Compute Cloud is one of its services which acts as an on-demand computing service on the cloud platform. From a computational point of view, it includes various different computing services as well as a virtual environment.

Steps to Create a New AWS Instance

To create a free AWS account refer to Amazon Web Services (AWS) – Free Tier Account Set up.

Step 1: Visit the AWS website and search for EC2 from various different available options.

Step 2: On the EC2 page, click on the Launch Instance button to create a new instance. There are different instance types. For more information, refer to Amazon EC2 – Instance Types

Step 3: Give a suitable name for your instance.

Step 4: Select UBUNTU as the Amazon Machine Image.


Step 5: Go to the Key-pair section, and create a new key-pair set (if you don’t have one already). Put a suitable name for your key and download it on your local machine. This key would help to log in to our instance using an SSH client.


Step 6: Click on the launch instance button on the right-hand bottom side to launch the instance.

Step 7: It will take a few seconds for the instance to start completely and go into a running state.


Connect to the Instance Using SSH Client

Step 1: Wait till the instance is up and running and after that click on Connect button on the top right-hand side of the page.

Step 2: Start the SSH client on your local system. (PuTTy for Windows, Terminal for Linux/MacOS).

Step 3: Go to the folder where you stored your private key file onto the terminal using the following command:

cd <path-to-your-folder>

Step 4: To give execute permission to the secret key file, execute the following command:

chmod 400 <privateKeyFile.pem>

Step 5: Connect to your instance using its public DNS. Copy the command given in the Example section and execute it on your terminal.


Step 6: After running this command, you will be asked “Are you sure you want to continue connecting (yes/no/[fingerprint])?”. Put “yes” and click Enter.

Step 7: You are now successfully connected to your instance on AWS from your local machine using an SSH client.

Install Python 2.7 on AWS Instance

Step 1: Before doing anything, let’s update the package list on our local system using the following command.

sudo apt update

Step 2: Follow the give command to install all dependencies which are important to follow basic linux operations.

sudo apt-get install build-essential


Step 3: The AWs EC2 does not offer installation capabilities of specific python versions. It can install python2.7 for a default version, but, to install a specific version like python2.7.8, we need to do the installation manually using the executable file. Use the given command to install such a file for python2.7.8 version.



Step 4: Check that the following file is a tar.gz file. So, use the following command to unzip this folder.

tar -xzyf Python-2.7.8.tgz


Step 5: Use the following command to check if the folder has been properly unzipped.


Step 6: After going inside the folder, use the following commands to finish the installation process for python2.7.8 version.

sudo make install




Step 7: The status of the installed python versin can be checked using the following command.

 python2.7 --version


FAQs on Install Python 2.8 on AWS EC2?

1. Why should any user install Python2.7 on EC2 instance, when the latest Python3 version is already available?

A user might be running some project which was previously developed on Python2.7, hence, he/she might need the older version in order to run it.

2. Does AWS EC2 allows user to create a virtual environment for Python2.7?

Yes, a virtual environment can be set up on any EC2 instance for Python2.7 using tools like “virtualenv”.

3. Why can’t we directly use package managers like apt or yum to install Python2.7 instead of installing it manually?

The package managers can be used to install Python2.7 on AWS EC2 instance, but, the default installation versions might vary. For any specific version, such as Python2.7.8, manual installation is necessary

4. Does AWS EC2 allow me to have Python2.7 and Python3 on same instance?

Yes, a user can install multiple Python versions on same EC2 instance.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads