Python is a popular programming language that is used for developing a wide range of applications, from web and mobile to scientific and data applications. In this article, we will show you how to install Python 3.9 on Rocky Linux 8.
Prerequisites
Before we begin, make sure that you have the following:
- A Rocky Linux 8 system with a non-root user with
sudoprivileges. - A stable internet connection.
Step 1: Update the System
First, update the package index and upgrade the installed packages by running the following command:
sudo dnf update
This will ensure that your system is up-to-date with the latest security patches and bug fixes.
Step 2: Install the Development Tools
Python is written in C, and it requires a C compiler and other development tools to be installed on your system. To install the development tools on Rocky Linux 8, run the following command:
sudo dnf group install "Development Tools"
This will install the C compiler, the make utility, and other required development tools on your system.
Step 3: Install Python 3.9
To install Python 3.9 on Rocky Linux 8, run the following command:
sudo dnf install python39
This will install the Python 3.9 package and its dependencies on your system.
To verify the installation, run the following command:
python3.9 -V
This will print the version number of the installed Python 3.9, along with other details.
Step 4: Set the Default Python Version
If you have multiple versions of Python installed on your system, you can use the update-alternatives command to set the default Python version.
To list the available Python versions on your system, run the following command:
sudo update-alternatives --config python
This will print a list of available Python versions along with their corresponding paths.
To set the default Python version, run the following command:
sudo update-alternatives --config python
This will prompt you to select the default Python version from the available options. Select the desired Python version and press Enter.
To verify the default Python version, run the following command:
python -V
This will print the version number of the default Python version, along with other details.
Here are few examples of using Python:
- Writing a command-line script to automate a task. For example, you could use Python to write a script that checks the availability of a domain name and registers it if it’s available.
- Developing a web application using a framework like Flask or Django. Python has a number of powerful web development frameworks that make it easy to build complex, dynamic websites and web applications.
- Building a machine learning model. Python has a number of powerful libraries for data analysis and machine learning, such as Pandas, NumPy, and scikit-learn, that make it a popular choice among data scientists and researchers.
- Creating a desktop application with a GUI. Python has a number of libraries for building graphical user interfaces, such as Tkinter, PyQt, and wxPython, that make it easy to create professional-looking desktop applications.
- Automating a task in your operating system. Python has a number of libraries for working with the file system and operating system, such as os and shutil, that make it easy to write scripts that can perform complex tasks with just a few lines of code.
Conclusion
In this tutorial, we have shown you how to install Python 3.9 on Rocky Linux 8. We have also shown you how to set the default Python version using the update-alternatives command. Python is a versatile programming language that is used for developing a wide range of applications. Try it out and see how it can help you build your next application.