Introduction
At the present time Python is a versatile and widely-used programming language, known for its simplicity and readability. If you’re working with Rocky Linux 9 and want to harness the power of Python 3.11, you’re in the right place. Explicitly In this comprehensive guide, we will walk you through the step-by-step process of installing Python 3.11 on Rocky Linux 9. Whether you’re a seasoned programmer or just starting your coding journey, you’ll have your Python environment up and running in no time. By following these instructions, you’ll be equipped to harness the power of the latest Python version for your projects.
Table of Contents
Why Upgrade to Python 3.11?
Basically Python 3.11 brings a host of improvements and new features that enhance the language’s capabilities. Some key highlights include:
- Performance Enhancements: Python 3.11 is designed to be faster and even more efficient, ensuring your code runs smoothly.
- New Syntax Features: Furthermore, the new release introduces syntax improvements that make the code more readable and concise.
- Security Updates: In addition, Python 3.11 includes security enhancements that protect your applications from potential vulnerabilities.
- Improved Standard Library: Moreover, the standard library has been expanded with new modules and updates, offering additional tools for your projects.
- Enhanced Error Messages: Additionally, debugging becomes easier with more informative and precise error messages.
Python versions, Release Dates and EOL:
Versions | Released Dates | End of life |
3.11 | 24 Oct 2022 | 24 Oct 2027 |
3.1 | 04 Oct 2021 | 04 Oct 2026 |
3.9 | 05 Oct 2020 | 05 Oct 2025 |
3.8 | 14 Oct 2019 | 14 Oct 2024 |
3.7 | 26 Jun 2018 | 27 Jun 2023 |
3.6 | 22 Dec 2016 | 23 Dec 2021 |
2.7 | 01 Oct 2008 | 29 Oct 2013 |
Basically by default, Rocky Linux 9 comes with Python version 3.9
[samm@rockylinux9 ~]$ python3 -V
Python 3.9.16
Step 1: System Update
Before beginning the installation process, it’s crucial to update your system’s package repositories and installed packages. Open a terminal and execute the following commands:
[samm@mysql ~]$ sudo dnf update -y
[samm@mysql ~]$ sudo dnf upgrade --refresh
Extra Packages for Enterprise Linux 9 - x86_64 9.5 kB/s | 6.5 kB 00:00
Extra Packages for Enterprise Linux 9 - x86_64 4.5 MB/s | 18 MB 00:04
Rocky Linux 9 - BaseOS 2.1 kB/s | 4.1 kB 00:01
Rocky Linux 9 - AppStream 3.3 kB/s | 4.5 kB 00:01
Rocky Linux 9 - Extras 1.8 kB/s | 2.9 kB 00:01
Dependencies resolved.
Nothing to do.
Additionally, this will update your package lists and upgrade installed packages to their latest versions.
[samm@mysql ~]$ sudo dnf upgrade -y
Step 2: Install required Dependencies
Before proceeding with Python 3.11 installation, ensure that certain prerequisites are present on your system. These prerequisites can be installed using the package manager by typing following command:
[samm@rockylinux9 ~]$ sudo dnf install vim gcc wget openssl-devel bzip2-devel libffi-devel -y
Last metadata expiration check: 0:04:43 ago on Thu 27 Jul 2023 05:21:56 AM EDT.
Package vim-enhanced-2:8.2.2637-20.el9_1.x86_64 is already installed.
Package wget-1.21.1-7.el9.x86_64 is already installed.
Package openssl-devel-1:3.0.7-16.el9_2.x86_64 is already installed.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing:
bzip2-devel x86_64 1.0.8-8.el9 appstream 214 k
libffi-devel x86_64 3.4.2-7.el9 appstream 29 k
Transaction Summary
===================================================================================================================================================================================================================
Install 2 Packages
Total download size: 242 k
Installed size: 343 k
Downloading Packages:
(1/2): libffi-devel-3.4.2-7.el9.x86_64.rpm 53 kB/s | 29 kB 00:00
(2/2): bzip2-devel-1.0.8-8.el9.x86_64.rpm 181 kB/s | 214 kB 00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 120 kB/s | 242 kB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libffi-devel-3.4.2-7.el9.x86_64 1/2
Installing : bzip2-devel-1.0.8-8.el9.x86_64 2/2
Running scriptlet: bzip2-devel-1.0.8-8.el9.x86_64 2/2
Verifying : bzip2-devel-1.0.8-8.el9.x86_64 1/2
Verifying : libffi-devel-3.4.2-7.el9.x86_64 2/2
Installed:
bzip2-devel-1.0.8-8.el9.x86_64 libffi-devel-3.4.2-7.el9.x86_64
Complete!
Furthermore, these libraries and development tools are essential for building Python from source.
Additionally, we recommend installing developer tools on the system.
[samm@rockylinux9 ~]$ sudo dnf -y groupinstall "Development Tools"
Last metadata expiration check: 0:05:38 ago on Thu 27 Jul 2023 05:21:56 AM EDT.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing Groups:
Development Tools
Transaction Summary
===================================================================================================================================================================================================================
Complete!
Step 3: Download Python 3.11 source files
After that we need to download Python 3.11 tarball from official website.
The version when this article cretaed is Python 3.11.4, you can download from official page.
[samm@rockylinux9 ~]$ wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz
Step 4: Extract and Compile Python
Then extract the downloaded source code and navigate to the extracted directory:
[samm@rockylinux9 ~]$ tar xvf Python-3.11.4.tgz
Afterwards switch to created folder after file extraction.
[samm@rockylinux9 ~]$ cd Python-3.11.4
Run configuration script with optimizations using following command:
[samm@rockylinux9 Python-3.11.4]$ ./configure --enable-optimizations
This step ensures Python is configured with optimizations for better performance indeed.
Step 5: Install Python 3.11 on Rocky Linux 9
Now compile and install Python 3.11 on Rocky Linux 9, proceed to build Python using the following commands:
[samm@rockylinux9 Python-3.11.4]$ sudo make -j <number_of_cores>
[samm@rockylinux9 Python-3.11.4]$ sudo make altinstall
Moreover, replace with the <number_of_cores>
on your system. By using altinstall
instead of install
, you prevent the replacement of the system’s default Python version, which helps maintain system stability.
Step 6: Verify Python Installation
After a successful installation confirm the version of Python on the system, run the following command:
[samm@rockylinux9 ~]$ python3.11 --version
Python 3.11.4
Furthermore, you should see the Python version displayed, indicating a successful installation.
As shown above do the same for pip
[samm@rockylinux9 ~]$ pip3.11 --version
pip 23.1.2 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
Step 7: Update Python PIP
PIP is the package installer for Python. Update it to the latest version, you can upgrade Pip3 using the following commands.
[samm@rockylinux9 ~]$ sudo /usr/local/bin/python3.11 -m pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.11/site-packages (23.1.2)
Collecting pip
Downloading pip-23.2.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 7.1 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.1.2
Uninstalling pip-23.1.2:
Successfully uninstalled pip-23.1.2
Successfully installed pip-23.2.1
Step 8: Install Python 3.11 Modules
A Python module, generally a file housing Python code, can encompass functions, variables, classes, constants, and executable code. Moreover, the majority of applications and development projects frequently employ modules for their self-contained nature, purposefully designed for reuse by other applications, as the name implies. The Python pip utility is used to install a module, but the import command is used to actually import the module.
pip3.11 install <module-name> --user
[samm@rockylinux9 ~]$ pip3.11 install awscli --user
Collecting awscli
Obtaining dependency information for awscli from https://files.pythonhosted.org/packages/88/d2/eee5beb22c39065e7e09a69634c6878a7ce500459bb06f7a5752a76e4613/awscli-1.29.12-py3-none-any.whl.metadata
Downloading awscli-1.29.12-py3-none-any.whl.metadata (11 kB)
Collecting botocore==1.31.12 (from awscli)
Obtaining dependency information for botocore==1.31.12 from https://files.pythonhosted.org/packages/29/22/d3313243e0e09ff421edb249011dbb8093089de76b84b5ec3438f4c868eb/botocore-1.31.12-py3-none-any.whl.metadata
Downloading botocore-1.31.12-py3-none-any.whl.metadata (5.9 kB)
Collecting docutils<0.17,>=0.10 (from awscli)
Downloading docutils-0.16-py2.py3-none-any.whl (548 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 548.2/548.2 kB 6.3 MB/s eta 0:00:00
Collecting s3transfer<0.7.0,>=0.6.0 (from awscli)
Downloading s3transfer-0.6.1-py3-none-any.whl (79 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.8/79.8 kB 4.7 MB/s eta 0:00:00
Collecting PyYAML<6.1,>=3.10 (from awscli)
Obtaining dependency information for PyYAML<6.1,>=3.10 from https://files.pythonhosted.org/packages/7b/5e/efd033ab7199a0b2044dab3b9f7a4f6670e6a52c089de572e928d2873b06/PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Downloading PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting colorama<0.4.5,>=0.2.5 (from awscli)
Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting rsa<4.8,>=3.1.2 (from awscli)
Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting jmespath<2.0.0,>=0.7.1 (from botocore==1.31.12->awscli)
Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
Collecting python-dateutil<3.0.0,>=2.1 (from botocore==1.31.12->awscli)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 4.3 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.25.4 (from botocore==1.31.12->awscli)
Obtaining dependency information for urllib3<1.27,>=1.25.4 from https://files.pythonhosted.org/packages/c5/05/c214b32d21c0b465506f95c4f28ccbcba15022e000b043b72b3df7728471/urllib3-1.26.16-py2.py3-none-any.whl.metadata
Downloading urllib3-1.26.16-py2.py3-none-any.whl.metadata (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.4/48.4 kB 1.6 MB/s eta 0:00:00
Collecting pyasn1>=0.1.3 (from rsa<4.8,>=3.1.2->awscli)
Downloading pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.9/83.9 kB 6.4 MB/s eta 0:00:00
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore==1.31.12->awscli)
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading awscli-1.29.12-py3-none-any.whl (4.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 8.8 MB/s eta 0:00:00
Downloading botocore-1.31.12-py3-none-any.whl (11.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.0/11.0 MB 7.4 MB/s eta 0:00:00
Downloading PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 757.7/757.7 kB 2.8 MB/s eta 0:00:00
Downloading urllib3-1.26.16-py2.py3-none-any.whl (143 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.1/143.1 kB 3.0 MB/s eta 0:00:00
Installing collected packages: urllib3, six, PyYAML, pyasn1, jmespath, docutils, colorama, rsa, python-dateutil, botocore, s3transfer, awscli
Successfully installed PyYAML-6.0.1 awscli-1.29.12 botocore-1.31.12 colorama-0.4.4 docutils-0.16 jmespath-1.0.1 pyasn1-0.5.0 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.6.1 six-1.16.0 urllib3-1.26.16
Conclusion
Finally Congratulations! You have successfully installed Python 3.11 on your Rocky Linux 9 system. By following this guide, you’ve ensured access to the latest Python features and optimizations for your coding projects. First thing to remember Python 3.11’s improved performance, new syntax features, and enhanced security make it a valuable tool for developers across various domains. Lastly with the knowledge now at your disposal for installing Python 3.11, embrace its capabilities and proceed to construct exceptional applications and scripts. Happy coding!
Also Read Our Other Guides :
- How To Install Python 3.11 from Source on Ubuntu 22.04
- How To Install Node.js on Rocky Linux 9 With 3 Different Ways
- How To Install Node.js on Ubuntu 22.04 With 3 Different Ways
- How To Install and Configure Elasticsearch on Ubuntu Server 22.04
- How To Install MySQL 8.0 on Ubuntu Server 22.04
- How To Install MariaDB 10.6 on Debian 11 Server
As I have shown, now you have learned how to install Python 3.11 from source on Rocky Linux 9.