Amazon Web Services logo

At the time of writing, the default Python installation on an EC2 instance running Amazon Linux AMI is Python 2.7 and can be found in


Installing Python 3 using

sudo apt-get install python3

won’t work as Amazon Linux AMI does not support


Use instead


Firstly, see what installation packages are available that could be a potential match

sudo yum list | grep python3

Then install the package wanted

sudo yum install python34

which places the files in


so no need to change


Now that we have an up-to-date version of Python, let’s take a look at installing packages. The best way to do so is use a package called pip.


returns a concise overview of how the package works. This default installation is located in


The pip package can be updated via

sudo pip install --upgrade pip

and doing so appears to move the installation to


as the executable in


no longer works.

pip list

returns the packages installed by pip. The list shows that there are several pre-installed packages which are in


or something similar.

Where do installed packages get saved?

pip --version


pip 7.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)

Let’s verify installed packages get saved in



pip install pyprimes

does not work and neither does

sudo pip install pyprimes

The former is due to a permission error, the latter as the super user has a different path variable to


and thus cannot resolve the command


To get round this, either change the super user path variable or, more simply, specify the full path of the pip executable

sudo `which pip` install pyprimes

To complete the verification,

pip show pyprimes


Metadata-Version: 1.1
Name: pyprimes
Version: 0.1
Summary: Generate and test for prime numbers.
Author: Steven D'Aprano
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python2.7/site-packages

To uninstall,

sudo `which pip` uninstall pyprimes

In Part 2, we’ll take a look at the virtualenv package.