The Wayback Machine - https://web.archive.org/web/20241001150652/https://www.geeksforgeeks.org/how-to-install-python3-on-aws-ec2/
Open In App

How to Install Python3 on AWS EC2?

Last Updated : 28 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer.

In this article, we will learn how to install Python on AWS EC2.

Prerequisite:

  1. AWS account.
  2. EC2 Instance.
  3. User with privileges to create Instance.

Installing Python on AWS EC2 :

Follow the below steps to install Python on AWS EC2:

Step 1: Create an AWS Elastic Cloud Compute Instance.

Step 2: Start the EC2 instance that you have created in Step 1.

Step 3: Connect to your EC2 Instance by clicking on Connect Button. 

Step 4: A prompt will pop up after connecting.

Step 5: Check if Python is already installed or not on our AWS EC2.

python --version

Step 6: At first update, Ubuntu packages by using the following command.

sudo apt update

Step 7: If Python3 is not installed on your AWS EC2, then install Python3 using the following command.

sudo apt-get install python3.7

Step 8: Wait for the process to end.

Step 9: We have successfully installed Python3 on AWS EC2, to check if Python3 is successfully installed or not, verify using the following command.

python3 --version

In this way, we can Install Python3 on our EC2 instance using EC2 Instance Connect.

Let’s try to create a Python program on nano and then execute that python program on our EC2 instance:

 

Python3




#example using python3 
#gfg.py
print("Geeks for Geeks is the best website for a programmer")


Output

Geeks for Geeks is the best website for a programmer

Output

Note: If you also use a free tier account, make sure you delete all the resources you have used before logging out. 

Setting up a virtual environment for Python on the EC2 instance:

This can be useful for isolating different Python projects and their dependencies, as well as for managing multiple versions of Python packages. To set up a virtual environment, you can use the virtualenv package, which can be installed using pip3 install virtualenv. Once virtualenv is installed, you can create a new virtual environment with a specific Python version by running the command virtualenv -p python3 envname, where envname is the name of your virtual environment. You can then activate the virtual environment using the command source envname/bin/activate. Within the virtual environment, you can install packages using pip3 install as usual, and they will be isolated from the global Python environment on the EC2 instance. When you are finished working in the virtual environment, you can deactivate it using the deactivate command.



Similar Reads

How To Get An AWS EC2 Instance ID From Within That EC2 Instance?
Amazon EC2 is an important service of AWS that provides users a scalable and virtual computing resources in the cloud. Each EC2 instance is assigned a unique identifier called Instance ID. Instance ID is an alphanumeric code(which means a combination of alphabets and numbers) that is used for various operational tasks including starting, stopping,
4 min read
How To Create An AWS EC2 Instance and Attach EBS to EC2 With Terraform?
Terraform is an IaaC tool, used to provision infrastructure on cloud platforms. In this guide, I will first discuss what is Terraform. Then I will discuss about AWS EC2 service. After this, I will walk you through the different steps to create an AWS EC2 Instance and attach an EBS volume to EC2 Instance using Terraform and then connect the EC2 Inst
6 min read
How To Create Spot Instance In Aws-Ec2 In Aws Latest Wizards?
Spot instances are available at up to 90% discount because when instances are not used then the instance available in spot instance at a cheaper rate so that people can utilize. it. When the demand increases then amazon sent a notification your spot instance will disappear after two minutes. We can use it for temporary work if our data losses it wi
6 min read
Create an EC2 Instance With EC2 User Data Script To Launch Website
Amazon EC2 is one of the most popular AWS offerings. It stands for Elastic Compute Cloud. This is the way to do Infrastructure as a Service on AWS. EC2 is not just one service. It's composed of many things at a high level. You can rent virtual machines on EC2, they're called EC2 instances.You can store data on virtual drives or EBS volumes.You can
9 min read
How to Install PHP on AWS EC2?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
How to Install Java JDK11 on AWS EC2?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
How to Install MySQL on AWS EC2?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
How to Install MongoDB on AWS EC2 Instance?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
How to Install Imagick for PHP on AWS EC2?
AWS or Amazon web services is a cloud service platform. It provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. Or in other words, EC2 is a virtual computer on which we can perform all our tasks and we have the au
2 min read
How to Install Go on AWS EC2?
EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer.Go is an open-source, statically typed, compiled programming language de
2 min read
How to Install R on AWS EC2?
R is widely used as a different programming language. There are several programming languages are present for different purposes. The C programming language is used to get basic knowledge in the programming field. Java programming language is used to get some deep knowledge of programming & its different applications. R programming language is
7 min read
How to Install Python 2.8 on AWS EC2?
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
4 min read
How To Install Docker On AWS EC2 ?
You can use the following instructions to install Docker on an AWS EC2 instance. Note that depending on the Linux distribution your EC2 instance is running, there may be differences in certain commands or processes. What is Docker?Docker is an OS-level virtualization that provides tools for building, running, testing, and deploying applications tha
3 min read
How to install Ansible in AWS EC2 Server ?
Ansible is an automation tool which helps in managing the configuration over multiple machines . On the other hand AWS EC2 is a web service which allows users to rent any required virtual server . Here in this guide, we will first discuss what is Ansible. Then we will discuss AWS EC2 Service. After this, we will walk you through the different steps
5 min read
How to Install an SSL/TLS Certificate In Amazon EC2 (AWS)
AWS EC2 is one of the most used and convenient solutions for hosting web servers and applications accessible worldwide. Securing your applications with an SSL certificate is vital for safeguarding user data and building trust. In this article, we will be hosting a basic web application on EC2 and will be generating and installing an SSL certificate
6 min read
What is AWS EC2 Instance Storage?
EC2 Instance storage is the temporary block storage service provided by AWS. EC2 instance storage, in itself, is not a storage service, but essentially it is a part of the EC2 service. These storage devices physically lie on the same host that provides the EC2 instance and are essentially useful to store temporary data associated with the EC2 insta
2 min read
Launching an EC2 instance using AWS CLI
In this article, we will look into the process of launching instances that is through AWS CLI(Command Line Interface). AWS CLI is a unified tool for running and managing your various AWS services. Just download and install the tool and you will be able to control multiple AWS services from the command line. For Developers, it is a great tool for ma
5 min read
Launching AWS EC2 Instance using Python
In this article, we will learn how python can be used for creating and managing Amazon Web Services (AWS) such as Elastic Compute Cloud (EC2), Simple Storage Service (S3), Relational Database Service (RDS). For this purpose, we will use boto3 library of python, Boto is a Python package that provides interfaces to Amazon Web Services (AWS). Prerequi
4 min read
How to Set Up Apache Web Server in AWS EC2 Linux (Ubuntu) Instance?
In this article, we will look into the process of setting up Apache Web Server in AWS EC2 Linux Instance.This tutorial has been done on a system running Windows 10 Home (Version 20H2). Implementation: The steps taken to complete this tutorial are being stated below: Step 1: Go to portal.aws.amazon.com to create a new AWS account. Provide email addr
4 min read
How to Configure C/C++ on AWS EC2?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
How to Configure Tomcat9 on AWS EC2?
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we
2 min read
Connecting an AWS EC2 Instance of a Private Subnet using Bastion Host
In this article, we will see how we can connect an instance present in a private subnet with the help of an instance present in a public subnet. Let us first have look over the following mentioned Key terminologies where we will first try to understand few things (like EC2 instance and other things) theoretically and then we will jump into the impl
8 min read
Allocate Elastic IP-Address to EC2 Instance in AWS
Pre-requisite: AWS When we launched the EC2 instance machines required IP-Address to communicate within a network or the internet. Amazon Web Services support IPv4 or IPv6 both and Amazon Web Services provide two option regarding IP-address to attach with EC2-Instance: Auto Assign IP-AddressManual Assign IP-Address (Elastic IP-Address)Auto Assign I
3 min read
Launch the EC2 Instance in AWS with New Instance Wizard
Pre-requisite:- EC2 EC2 stands for Elastic Compute Cloud and it is an AWS web service for on-demand computing service. It is based on the pay-as-you-go model. We can create instances anytime from anywhere via the internet. We can easily create the instance or terminate the instance within minutes with our required operating system. we can configure
2 min read
How to Deploy Django Application in AWS EC2?
In this article, we will study how we can deploy our existing Django web application to Windows Server in AWS EC2. We will also see how to use the public IP of the EC2 instance to access the Django application. For this article, you should know about setting up EC2 in AWS. We will see how to deploy applications on Linux As Well as Windows OS. Intro
3 min read
Deploy Node-Express Server in AWS EC2 Instance
AWS or Amazon Web Services is a leading cloud services provider which gives access to a number of on-demand computational services, databases, storage space, etc.EC2 or Elastic Compute Cloud is an on-demand computing service on the AWS cloud platform. Under computing, it includes all the services a computing device can offer to you along with the f
5 min read
Django Web Application Deployment On AWS EC2 With Windows Server
In this article, we will study how we can deploy our existing Django web application to Windows Server in AWS EC2. We will also see how to use the public IP of the EC2 instance to access the Django application. For this article, you should have knowledge about setting up EC2 in AWS. So let's proceed with the article. What is Django?Django is a Pyth
4 min read
AWS EC2 On Demand and Spot Instances
In this article, we are going to understand difference between EC2 On demand and Spot instances. We are going to learn their usage and working. it is important to understand the difference between AWS EC2 On Demand and Spot Instances so that you can choose right instances for your business requirement. AWS EC2 (Elastic Compute Cloud) is a cloud com
6 min read
Mount AWS S3 Bucket On Amazon EC2-Instance
AWS S3 storage service is used for object storage these objects can be termed a file and it's metadata that briefs about it. Well, to store the files and documents we need to create a S3 bucket. It's like a container that stores the files. These files can be pictures, txt file, documents, static web page files, etc. AWS S3 object storage is mostly
3 min read
Website Development with Jenkins Job on AWS-EC2
Pre-requisites: AWS, Jenkins, Git&Github  Jenkins is a popular open-source automation server that helps to automate different stages of software development, including building, testing, and deploying applications. It is a powerful tool that is widely used in DevOps environments to automate the process of continuous integration and continuous d
4 min read
Practice Tags :