Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo yum update -y- Install Python
RHEL typically comes with Python pre-installed. However, you can install the latest versions of Python using theyumpackage manager:
sudo yum install python3 -yThis command installs Python 3.
- Verify Python Installation
Check the Python version to ensure it is installed correctly:
python3 --versionYou should see the Python version information displayed.
- Verify pip Installation
Check ifpip, the Python package installer, is installed:
pip3 --versionIf pip is not installed, you can install it using:
sudo yum install python3-pip -y- Install Virtualenv (Optional)
It’s a good practice to use virtual environments for your Python projects. Installvirtualenvusingpip:
sudo pip3 install virtualenv- Create a Virtual Environment (Optional)
Create a new virtual environment for your project:
virtualenv venvActivate the virtual environment:
source venv/bin/activateYour command prompt should change to indicate that the virtual environment is active.
- Install Packages with pip
You can now install Python packages within your virtual environment usingpip. For example, to install Flask, a popular web framework, use:
pip install flask- Deactivate the Virtual Environment
When you are done working in the virtual environment, deactivate it:
deactivate- Create a Simple Python Script
To test your Python installation, create a simple Python script:
nano hello.pyAdd the following code to the file:
print("Hello, World!")Save and close the file.
- Run the Python Script
Execute the script to ensure Python is working correctly:bash python3 hello.py


