Python is an incredibly popular programming language known for its simplicity, versatility, and large collection of libraries. It’s used in various fields such as web development, data analysis, artificial intelligence, and more. In this guide, we will walk you through the process of how to install Python on Rocky Linux, a community-driven enterprise Linux distribution.
Prerequisites
Before installing Python, make sure you have an updated version of Rocky Linux. You can update your system using the following command:
sudo dnf update -y
How to Install Python on Rocky Linux
Check the Current Python Version
By default, Rocky Linux comes with a pre-installed version of Python. To check the current version, use the following command:
python3 --version
If the Python version installed on your system meets your requirements, you can skip the rest of this guide.
Install Python from the Default Repository
If you need a different version of Python, you can easily install it from the default repository. To install Python 3.9, for example, run the following command:
sudo dnf install -y python39
Once the installation is complete, check the newly installed Python version with:
python3.9 --version
Install Python from the EPEL Repository
For a more extensive selection of Python versions, you can enable the Extra Packages for Enterprise Linux (EPEL) repository. First, install the EPEL repository with the following command:
sudo dnf install -y epel-release
After installing the EPEL repository, update the package list:
sudo dnf update -y
Now you can install any available Python version from the EPEL repository. For example, to install Python 3.10, run the following command:
sudo dnf install -y python310
Check the installed Python version with:
python3.10 --version
Set the Default Python Version
If you have multiple Python versions installed on your system, you might want to set a specific version as the default. To do this, use the alternatives
command. For example, to set Python 3.10 as the default, run the following commands:
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
You can change the priority number (1 or 2 in this example) to set the preferred Python version. To check the current default version, use the following command:
python3 --version
Additional Resources
After installing Python on Rocky Linux, you might be interested in installing other software to enhance your development environment. Check out the following guides:
- How to Install Git on Rocky Linux
- How to Install Ruby on Rocky Linux
- How to Install Vim on Rocky Linux
- How to Install Wget on Rocky Linux
- How to Install TensorFlow on Rocky Linux
Conclusion
Now you know how to install Python on Rocky Linux and set the default version according to your needs. With Python installed, you can start developing your applications, automating tasks, or analyzing data. The Python ecosystem offers a wide range of libraries and frameworks, so you’ll never run out of tools to enhance your projects.
Remember to keep your Python environment up-to-date to ensure that you have access to the latest features and security updates. Regularly check for updates using the dnf update
command:
sudo dnf update -y
To further improve your Rocky Linux experience, you might want to explore additional guides on setting up various server components and tools:
- How to Install MySQL on Rocky Linux
- How to Install MariaDB on Rocky Linux
- How to Install PHP on Rocky Linux
- How to Install phpMyAdmin on Rocky Linux
- How to Change SSH Port on Rocky Linux
We hope you find this guide useful and that it helps you get started with Python on Rocky Linux.