Setup an Interactive Python Shell on Your Local Machine

A tutorial that covers some of the basics to help you start playing around with Python

By Rob Johnson

Mon Aug 16 2021

# tutorial # python # aws

Python has gained support and popularity in the development space due to its powerful ability to perform statistical calculations along with enterprise support from the likes of AWS in using it for ETL processes.

Below is an overview of the basics, along with a lambda script overview.

Bash Terminal

First open up a bash shell if you're on Windows, or the "Terminal" application if you're on Mac OS.

Find out the version you're running by entering:

python --version

Currently, I'm using Python 2.7.18

Anything 2+ is fine for what we're doing. If you need to upgrade, download the latest release here.

Keeping it Simple with iPython

iPython is an enhanced interactive shell for Python. It adds improved syntax highlighting and tools far beyong what we're doing today, but worth installing to improve the developer experience. Additional benefits include (from project homepage):

Type the following to initiate the install

pip3 install ipython

Verify the location of your install

which ipython

You should see something like ~/local/bin/ipython

Now start the shell by simply typing

ipython

This has now initiated an interactive shell for Python using iPython. You can enter the code you want to use in your script.

Now you could type Python as you would expect. Simple example below (hit enter after each line):

order_1 = 120
order_2 = 300
total = order_1 + order_2
# total would now equal 420
# show the variable value by typing the variable name and hitting enter
total

This is a simple way to get started with Python and learn the basics.

You can also import packages that will help you do more such as boto3, which is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python.

import boto3

Fun bonus for AWS

You can follow the same process here for an AWS Cloud Shell which is located at the top right of the AWS Console. This Cloud Shell will inherit all the same permissions that your AWS Console user has.


# commerce 4 # seo 3 # productivity 1 # tutorial 14 # sql 3 # javascript 7 # projects 4 # git 2 # php 3 # analytics 3 # ux 1 # python 2 # aws 2 # mobile 1