Running Python scripts on an AWS EC2 Instance

Praneeth Kandula
4 min readNov 27, 2018

So you have an EC2 instance up and running on AWS (If you don’t have it already, take a look at this post: https://medium.com/@praneeth.jm/launching-and-connecting-to-an-aws-ec2-instance-6678f660bbe6).

Now let’s see how we can setup a python environment, transfer python scripts from your local machine to the remote instance and run them.

AWS EC2 Instance on Putty

To see everything that’s installed in your instance, type in the following commands:

cd /usr/bin/
ls
  1. You will probably see python 2.7 already installed which is the older version, so let’s go ahead and install python 3.6
sudo yum install python36

Even after installing python 3.6, running python --version in the Putty terminal still points to python 2.7, let’s change that.

alternatives --set python /usr/bin/python3.6python --version

What we did there is, change the default python to the newer version, it should now point to python 3.6.

2. Next we want to install pip3 that we will use to install python packages.

cd /tmp
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
pip3 --version

--

--

Responses (12)