How to Install Python 3.12 on AlmaLinux
Python, the versatile and powerful programming language, is a must-have on your AlmaLinux server. Follow this simple guide to install Python 3.12 and unlock a world of possibilities.
Prerequisites:
- A fresh installation of AlmaLinux with root or sudo access.
Step 1: Update System Packages
Before diving into Python, ensure your system is up to date:
sudo dnf update -y
Step 2: Install Development Tools
Install essential development tools and libraries:
sudo dnf groupinstall "Development Tools" -y
sudo dnf install wget openssl-devel libffi-devel -y
Step 3: Download and Compile Python 3.12
- Fetch the Python 3.12 source code and compile it:
wget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz
tar xzf Python-3.12.1.tgz
cd Python-3.12.1
- Configure the Build:
./configure --enable-optimizations
💡
This command configures the build, enabling optimizations for the specific system architecture. It tailors the Python installation to take full advantage of the host machine's capabilities.
- Build Python:
make -j8
💡
The make command compiles the Python source code. The -j8 flag allows parallel compilation, utilizing 8 processors (you can adjust the number based on your machine's capabilities). This speeds up the compilation process.
- Install Python:
sudo make altinstall
💡
The make altinstall command installs Python without replacing the system's default Python interpreter. This avoids potential conflicts with the operating system. The use of sudo grants the necessary permissions for system-level installation.
Step 4: Verify Python Installation
Check that Python 3.12 is installed:
python3.12 -V
Conclusion:
Congratulations! Python 3.12 is now successfully installed on your AlmaLinux server. Dive into the Python world and start building amazing projects. If you have any questions, feel free to ask in the comments below. Happy coding!