Installing Python on Amazon aws Linux 2 server is not difficult, just download Python latest version zip using the wget command and then extract it, and run the sudo ./configure --enable-optimizations && sudo make altinstall
command to install it in your AWS Linux 2 server.
How To Install Python 3.12 on Amazon Linux 2
Here are some steps for installing Python 3.12 on Amazon AWS linux 2:
Step 1 – Login to Amazon AWS Linux 2 Console
Log into the AWS EC2 Management Console.
Step 2 – Connect to Amazon AWS Linux 2 Server via SSH
To connect your Amazon AWS linux 2 server from the SSH terminal, Open your putty or ssh and connect to from server.
If you are new to connect aws ec2 instance with Windows, ubuntu, and mac systems. A step-by-step guide on How to Connect to ec2 Instance From Putty and SSH Terminal.
Step 3 – Update System
Before you can install Python 3.12, you need to update your Amazon AWS Linux 2 system and install some Python-related packages, which you can do with the following commands:
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
Step 4 – Download Python 3.12 on Amazon aws Linux 2
Now you just need to type the command wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
on amazon aws ssh terminal and press enter for downloading python 3.12 on amazon aws linux 2 system:
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
Python 3.12 version has been downloaded with the help of wget command, now you have to type tar xzf Python-3.12.0.tgz
command to extract it on your amazon aws linux 2 server:
tar xzf Python-3.12.0.tgz
Step 5 – Install Python 3.12 on Amazon aws Linux 2
Simply navigate to the Python-3.12.0 directory by using cd python-3.12.0
command:
cd Python-3.12.0
And after that, use sudo ./configure –enable-optimizations command aws linux 2 ssh terminal window and press enter to install python 3.12:
sudo ./configure --enable-optimizations
Next, compile python by using sudo make altinstall
command on ssh terminal window:
sudo make altinstall
Step 6 – Verify Python Installation
To run python3 -V
command on aws ssh terminal to verify python 3.12.0 installation on amazon aws linux 2 server
python3 -V
The output will be:
Python 3.12.0
Conclusion
That is all; You have learned how to install Python 3.12 from source code on an Amazon AWS Linux 2 server.