Run python program in AWS ec2 Linux using instance connect

Abimuktheeswaran Chidambaram
3 min readMar 3, 2024

--

This article shows how to write and execute the Python program in an AWS EC2 Linux instance using Instance Connect.

Requirements:

An AWS account may be a free tier or a paid tier.

Steps:

  1. Create and launch the Linux instance with its default settings.

2. connect the instance.

3. connect the instance using ec2 instance connect.

Your ec2 instance connect window will open like this

4. Now type the following commands

sudo su to temporarily grant users or user groups privileged access to system resources.

yum update to update the applications in a system.

Type the command yum install python3-pip to install python using pip.

Type the command python3 -m pip install pandas to install pandas.

Type the command python3 -m pip install sympy to install sympy.

create the directory named “aaa”. By typing the command as mkdir aaaa. Go to the terminal window by typing the command nano <filename.py>. Here my filename is a sample.py

your terminal window looks like this. To save the code by ctrl+s and exit from the terminal window by ctrl+x.

After exiting from the window. Type the command ls. Your saved filename will appear here. then run the file by using the command python3 <filename.py>

Thanks for reading!

--

--