Python is one of the widely used object-oriented programming languages. It is a free and open-source programming language that can be used to build innumerable applications ranging from small, simple scripts to complex machine learning algorithms.
Python was invented by Guido van Rossum as a general-purpose programming language and ever since, it has gained immense popularity due to its simplicity, easy-to-learn syntax, and a massive community of developers behind it.
Python 3.13.0 is the newest major release of the Python programming language, and it contains many new features and optimizations compared to Python 3.12. Let’s have a look.
- A new and improved interactive interpreter, based on PyPy‘s, featuring multi-line editing and color support, as well as colorized exception tracebacks.
- An experimental free-threaded build mode, which disables the Global Interpreter Lock, allowing threads to run more concurrently. The build mode is available as an experimental feature in the Windows and macOS installers as well.
- A preliminary, experimental JIT, providing the ground work for significant performance improvements.
- The
locals()
builtin function (and its C equivalent) now has well-defined semantics when mutating the returned mapping, which allows debuggers to operate more consistently. - A modified version of mimalloc is now included, optional but enabled by default if supported by the platform, and required for the free-threaded build mode.
- Docstrings now have their leading indentation stripped, reducing memory use and the size of .pyc files. (Most tools handling docstrings already strip leading indentation.)
- The dbm module has a new dbm.sqlite3 backend that is used by default when creating new files.
- The minimum supported macOS version was changed from 10.9 to 10.13 (High Sierra). Older macOS versions will not be supported going forward.
Python is useful in the following areas:
- In rapid prototyping or production-ready software development.
- Used in creating web applications.
- Connecting to database systems, reading and modifying files.
- Handling big data and performing complex mathematics.
- It is used alongside software to create workflows.
Python being a cross-platform language, it can be installed and run on Windows, Linux, macOS, and BSD operating systems. By the end of this guide, you should be able to install Python 3.13 on Amazon Linux 2.
Getting Started.
Before we dive into the crux of this guide, we need to have our Amazon Linux 2 system updated and the required tools installed.
sudo yum update -y
sudo yum groupinstall "Development Tools" -y
sudo yum erase openssl-devel -y
sudo yum install openssl11 openssl11-devel libffi-devel bzip2-devel wget -y
Since we are going to install Python 3.13 on Amazon Linux 2 by building it from the source, the above dependencies are necessary.
Check the installed version of GCC.
$ gcc --version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-17)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The reason why we are installing Python 3.13 on Amazon Linux 2 by building it from source is that the available versions in the default repositories are not up to date.
$ amazon-linux-extras | grep -i python
44 python3.8 available [ =stable ]
Step 1 – Download Python 3.13 on Amazon Linux 2
Download the latest version of Python, 3.13 by visiting the official Python release page. Alternatively, obtain the download link and pull the archive using Wget as below.
wget https://www.python.org/ftp/python/3.13.1/Python-3.13.1.tgz
Extract the downloaded Python 3.10 archive.
tar -xf Python-3.13.1.tgz
Now switch to the extracted directory.
cd Python-3.13.1/
Step 2 – Install Python 3.13 on Amazon Linux 2
Now from the directory, execute the below configure
script to check if the required dependencies are available. The –-enable optimization
flag is so necessary as it optimizes the binary through running multiple tests.
./configure --enable-optimizations --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
Sample Output:
...
checking for stdlib extension module _hashlib... yes
checking for stdlib extension module _testcapi... yes
checking for stdlib extension module _testclinic... yes
checking for stdlib extension module _testclinic_limited... yes
checking for stdlib extension module _testlimitedcapi... yes
checking for stdlib extension module _testinternalcapi... yes
checking for stdlib extension module _testbuffer... yes
checking for stdlib extension module _testimportmultiple... yes
checking for stdlib extension module _testmultiphase... yes
checking for stdlib extension module _testsinglephase... yes
checking for stdlib extension module _testexternalinspection... yes
checking for stdlib extension module xxsubtype... yes
checking for stdlib extension module _xxtestfuzz... yes
checking for stdlib extension module _ctypes_test... yes
checking for stdlib extension module xxlimited... yes
checking for stdlib extension module xxlimited_35... yes
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/Setup.bootstrap
config.status: creating Modules/Setup.stdlib
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: creating Modules/Setup.local
configure: creating Makefile
Initiate the Python 3.13 build process. In the command, the -j
flag is used to specify the number of cores on your system. This makes the process faster. Get the number of cores available on your Amazon Linux 2 system using:
$ nproc
4
From the output, I have 4 cores and therefore I will run the make command as below.
make -j $(nproc)
Sample Output:
...
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for Python interpreter freezing... ./_bootstrap_python
checking for python3.13... no
checking for python3.13... no
checking for python3.12... no
checking for python3.11... no
checking for python3.10... no
checking for python3... no
checking for python... python
checking Python for regen version...
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking MACHDEP... "linux"
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking for --with-app-store-compliance... not patching for app store compliance
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
...
...
The necessary bits to build these optional modules were not found:
_curses _curses_panel _dbm
_gdbm _lzma _tkinter
_uuid readline
To find the necessary bits, look in configure.ac and config.log.
Checked 112 modules (33 built-in, 69 shared, 1 n/a on linux-x86_64, 1 disabled, 8 missing, 0 failed on import)
make[1]: Leaving directory `/home/cloudspinx/Python-3.13.1'
Once complete, install Python 3.13 on Amazon Linux 2 using the command:
sudo make altinstall
Note that the altinstall
is used to keep the default Python path at /usr/bin/python
Sample Output:
...
/usr/bin/install -c -m 755 Modules/xxlimited_35.cpython-313-x86_64-linux-gnu.so /usr/local/lib/python3.13/lib-dynload/xxlimited_35.cpython-313-x86_64-linux-gnu.so
/usr/bin/install -c -m 644 ./Misc/python.man \
/usr/local/share/man/man1/python3.13.1
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--altinstall --upgrade" ;; \
install|*) ensurepip="--altinstall" ;; \
esac; \
LD_LIBRARY_PATH=/home/cloudspinx/Python-3.13.1 ./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmp9mspiiat
Processing /tmp/tmp9mspiiat/pip-24.3.1-py3-none-any.whl
Installing collected packages: pip
WARNING: The script pip3.13 is installed in '/usr/local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-24.3.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
That is it! You have successfully installed Python 3.13 on Amazon Linux 2. Verify this by checking the installed Python version as below.
$ python3.13 --version
Python 3.13.1
Step 3 – Install Python Modules and Extensions
With Python installed, it is preferred you install modules and extensions to add functionality to it. These modules and extensions can be installed using the Python Package manager commonly abbreviated as PIP. Install PIP on Amazon Linux 2 using the command below.
sudo yum install python3-pip
Now that PIP has been installed, installing extensions|modules becomes easy. Use the syntax:
sudo pip install module-name
Let’s exercise this by installing the Klon module as below. Remember, you can see the list of Python modules from the Python Modules page
python3.13 -m pip install klon
Check the list of installed Python packages:
$ pip3.13 list
Package Version
------------------ ---------
certifi 2021.10.8
charset-normalizer 2.0.12
idna 3.3
klon 2.3.0
lxml 4.8.0
lxml-stubs 0.1.1
pip 22.0.4
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
Step 4 – Create a Python Virtual Environment
A place where Python libraries, Python interpreters, and Python scripts are installed is known as a Python Virtual Environment. This environment can be created on Amazon Linux 2 as below.
First, create a project directory. In this guide, we will name it sample_app.
mkdir ~/sample_app && cd ~/sample_app
While in the created directory, create a Virtual Environment as below.
python3.13 -m venv sample_app_venv
Proceed and activate the environment.
source sample_app_venv/bin/activate
The environment will be activated as below.
(sample_app_venv) [cloudspinx@amazonlinux sample_app]$
Now you are in the shell and the name of the project/app is prefixed. Deactivate/exit from the environment with the command:
deactivate
Congratulations! This is the end of this guide on how to install Python 3.13 on Amazon Linux 2. I hope you learned a lot.
Interested in more: