Home » Blog » How TO » Steps to Install Python 3.9 on Amazon Linux 2

Steps to Install Python 3.9 on Amazon Linux 2

Steps to Install Python 3.9 on Amazon Linux 2

Steps to Install Python 3.9 on Amazon Linux 2, In today’s article we shall be performing an installation of Python 3.9 on Amazon Linux 2. Python is an open source, powerful, and easy to master programming language. It is very popular in the fields of data science, machine learning and AI.

Despite its development starting out as a hobby project, it is now a widely used programming language in the world. Python is created to be simple, efficient, but with effective approach to object-oriented programming.

Python 3.9 was first released in 2020-10-05 and is expected enter its end of support in 2025-10. Below are some key features available in Python 3.9 release.

  • PEP 573, Module State Access from C Extension Methods
  • PEP 584, Add Union Operators To dict
  • PEP 585, Type Hinting Generics In Standard Collections
  • PEP 593, Flexible function and variable annotations
  • PEP 614, Relaxing Grammar Restrictions On Decorators
  • PEP 615, Support for the IANA Time Zone Database in the Standard Library
  • PEP 616, String methods to remove prefixes and suffixes
  • PEP 617, New PEG parser for CPython

Install Python 3.9 on Amazon Linux 2

In this blog post we shall perform an installation of install Python 3.9 on Amazon Linux 2 system. Many libraries are freely available in source for all major platforms from https://www.python.org/. They enable you to extend Python features.

Install Python build dependencies

A number of dependencies are required of building Python 3.9 on Amazon Linux 2 from source. Install them by running the following commands in the terminal

sudo yum -y groupinstall "Development Tools"
sudo yum -y install openssl-devel bzip2-devel libffi-devel

Verify gcc and make tools installation

$ gcc --version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-13)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

$ make --version
GNU Make 3.82
Built for x86_64-koji-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Download and buildPython 3.9 on Amazon Linux 2

DownloadPython 3.9 source

sudo yum -y install wget
wget https://www.python.org/ftp/python/3.9.10/Python-3.9.10.tgz

Extract downloaded file

tar xvf Python-3.9.10.tgz

Build and installPython 3.9 on Amazon Linux 2

cd Python-*/
./configure --enable-optimizations
sudo make altinstall

If installation ofPython 3.9 on Amazon Linux 2 was successful, the check version command should show correctly;

$ python3.9 --version
Python 3.9.10

Pip is also installed on your system with Python 3.9

$ pip3.9 --version
pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

Upgrade pip

$ /usr/local/bin/python3.9 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (21.2.4)
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 11.1 MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1

Test installation of module using pip3.9

$ pip3.9 install awscli --user
Collecting awscli
  Downloading awscli-1.22.13-py3-none-any.whl (3.8 MB)
     |████████████████████████████████| 3.8 MB 26.4 MB/s
Collecting rsa<4.8,>=3.1.2
  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting PyYAML<5.5,>=3.10
  Downloading PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl (630 kB)
     |████████████████████████████████| 630 kB 38.2 MB/s
Collecting botocore==1.23.13
  Downloading botocore-1.23.13-py3-none-any.whl (8.2 MB)
     |████████████████████████████████| 8.2 MB 31.7 MB/s
Collecting docutils<0.16,>=0.10
  Downloading docutils-0.15.2-py3-none-any.whl (547 kB)
     |████████████████████████████████| 547 kB 39.1 MB/s
Collecting colorama<0.4.4,>=0.2.5
  Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting s3transfer<0.6.0,>=0.5.0
  Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 17.6 MB/s
Collecting jmespath<1.0.0,>=0.7.1
  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting python-dateutil<3.0.0,>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 34.5 MB/s
Collecting urllib3<1.27,>=1.25.4
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 38.2 MB/s
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 13.6 MB/s
Installing collected packages: six, urllib3, python-dateutil, jmespath, pyasn1, botocore, s3transfer, rsa, PyYAML, docutils, colorama, awscli
Successfully installed PyYAML-5.4.1 awscli-1.22.13 botocore-1.23.13 colorama-0.4.3 docutils-0.15.2 jmespath-0.10.0 pyasn1-0.4.8 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.5.0 six-1.16.0 urllib3-1.26.7

This confirms our installation of Python 3.9 and Pip3.9 on Amazon Linux 2 to be successful. You can check more guides on Amazon Linux 2 available on our website.

Scroll to Top