How to Install Python 3.12 on Alma Linux 9

Choose a different version or distribution

Introduction

Before we begin talking about how to install Python 3.12 on AlmaLinux 9, let's briefly understand – What is Python?

Python is a popular programming language known for its simplicity and versatility. It is widely used for web development, data analysis, artificial intelligence, and more. Python's clear syntax and readability make it easy for beginners to learn.

With a large community of developers and countless libraries, Python is ideal for building scalable and efficient applications. Whether you are a beginner or an experienced programmer, Python is a valuable tool to have in your toolkit.

In this tutorial, you will install Python 3.12 on AlmaLinux 9. We will also address a few FAQs on how to install Python 3.12 on AlmaLinux 9.

Advantages of Python 3.12

  1. Improved Error Messages: Enhanced error messages with helpful suggestions and guidance for better debugging and user experience.
  2. Enhanced f-strings: More flexible f-strings for multi-line expressions and comments, making code more readable and maintainable.
  3. Performance Boosts: Optimizations and inlined comprehensions for faster execution, particularly in asynchronous programming.
  4. Type Variables and Aliases: New syntax for generic types and aliases, promoting clearer code with static type checkers.
  5. Security Enhancements: Formal verification for built-in hash functions, ensuring more secure code and better protection against vulnerabilities.

Update System Packages

It's always a good idea to update system packages before installing Python 3.12.

sudo yum update

Install Development Tools

To build and install modules for Python, development tools are needed. Utilizing the following command, install the required tools:

sudo yum groupinstall "Development Tools"

Install Dependencies

Prior to building from source, you must install a few dependencies for Python:

sudo yum install openssl-devel bzip2-devel libffi-devel

Download and Extract Python 3.12

Visit the Python download page to obtain the Python 3.12 source code. After downloading, open the tarball or zip file and extract the files.

Compile and Install Python

Open the extracted directory, then type the following commands there:

./configure

make

sudo make install

Verify Installation

Once the installation is finished, run the following to confirm that Python 3.12 is installed:

python3.12 --version

Output:

Setting Up Virtual Environments (Optional)

For the purpose of separating Python projects, using virtual environments is advisable. Install the venv module that comes with Python.

sudo yum install python3-venv

You can use it for any Python-related task, scripting, or development projects you have. Don't forget to maintain an updated Python installation for enhanced security and efficiency!

FAQs to Install Python 3.12 on AlmaLinux 9

Is Python 3.12 available in the default AlmaLinux 9 repositories?

No, Python 3.12 is not available in the default AlmaLinux 9 repositories. You need to add the EPEL (Extra Packages for Enterprise Linux) repository to install Python 3.12.

How do I add the EPEL repository to AlmaLinux 9?

You can add the EPEL repository by running the command sudo dnf install epel-release. This will add the EPEL repository to your system.

Can I install multiple versions of Python on AlmaLinux 9?

Yes, you can install multiple versions of Python on AlmaLinux 9. Python 3.12 can coexist with other versions of Python, such as Python 3.10 or Python 3.8.

Are there any dependencies required for installing Python 3.12 on AlmaLinux 9?

Yes, Python 3.12 requires the libffi and libzstd packages to be installed. You can install these packages using the command sudo dnf install libffi libzstd.

Can I use pip to install packages for Python 3.12 on AlmaLinux 9?

Yes, you can use pip to install packages for Python 3.12 on AlmaLinux 9. The pip package manager is included with Python 3.12.

Are there any known issues with installing Python 3.12 on AlmaLinux 9?

No, there are no known issues with installing Python 3.12 on AlmaLinux 9. Python 3.12 is compatible with AlmaLinux 9 and can be installed without any issues.

How do I uninstall Python 3.12 on AlmaLinux 9?

You can uninstall Python 3.12 on AlmaLinux 9 using the package manager, dnf. Run the command sudo dnf remove python3.12 to uninstall Python 3.12.

Conclusion

We hope this tutorial helped you understand how to install Python 3.12 on AlmaLinux 9.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.