Python, an open-source, versatile, and powerful language, is popular for a variety of applications, from web development to data analysis and machine learning. Whether you are a seasoned developer or a beginner, knowing how to install Python on your system is essential.
This guide will walk you through the process of installing Python on Rocky Linux 9, a community-driven Linux distribution which aims to provide a production-ready enterprise software experience.
Preparing the System
Before you start the Python installation process, it’s essential to ensure that your system is up-to-date. Open the Terminal and execute the following command:
sudo dnf update -y
Enter your password when prompted. The -y option will allow the operation to proceed without waiting for your confirmation.
Checking for Pre-Installed Python
Many Linux distributions come with a version of Python pre-installed. To check this, use the following command:
python3 --version
If Python 3 is installed, the system will output the version number. If not, you’ll see an error message.
Installing Python
Rocky Linux 9 uses the DNF package manager, making the Python installation process straightforward.
- Installing Python 3
To install Python 3, use the following command:
sudo dnf install -y python3
Again, the -y option is used to allow the operation to proceed without user confirmation.
- Checking the Installation
After the installation is complete, you can verify it by checking the version of Python. Use the following command:
python3 --version
The system should now output the version of Python that was installed.
Installing pip
pip, the Python package installer, is an essential tool for working with Python. It allows you to install and manage additional packages that are not part of the Python standard library.
- Installing pip
To install pip for Python 3, use the following command:
sudo dnf install -y python3-pip
- Checking the Installation
Verify the successful installation of pip by checking its version:
pip3 --version
The system should display the version of pip that was installed.
Upgrading pip
It’s a good practice to ensure that pip is up-to-date. To upgrade pip, use the following command:
pip3 install --upgrade pip
Conclusion
That’s it! You’ve successfully installed Python and pip on Rocky Linux 9. You can now proceed with the installation of additional Python packages as per your requirements, using the pip installer. Remember to keep your Python environment up-to-date to take advantage of the latest features and security patches. This is as simple as periodically running sudo dnf update -y
for system-wide packages, and pip3 install --upgrade package_name
for individual Python packages. Happy coding!