How to Install Python 3 on CentOS 7
Python is one of the most widely used programming languages, known for its simplicity and versatility. Whether you’re developing web applications, data science projects, or automation scripts, Python is an essential tool for developers. While CentOS 7 server comes with Python 2.x by default, many modern applications and frameworks now require Python 3. In this article, we will walk you through the steps to install Python 3 on CentOS 7, ensuring you can work with the latest version of Python.
Prerequisites
Before installing Python 3, you need to ensure your system is updated and that you have root or sudo privileges. This will help avoid any permission issues during installation.
Access to a CentOS 7 server
Root or sudo privileges
Basic knowledge of using the command line
Step 1: Update the System
It’s always a good idea to update your system packages before installing new software. Open a terminal and run the following command to update your CentOS 7 system:
sudo yum update -yThis will ensure that all existing packages are up to date and any security patches are applied.
Step 2: Enable EPEL Repository
The Extra Packages for Enterprise Linux (EPEL) repository contains additional packages that are not included in the default CentOS repositories. To install Python 3 on CentOS 7, you will need to enable the EPEL repository first.
To enable the EPEL repository, run the following command:
sudo yum install epel-release -yOnce the repository is enabled, your system will have access to a wide range of additional packages, including Python 3.
Step 3: Install Python 3
Now that the EPEL repository is enabled, you can proceed to install Python 3. CentOS 7 uses the
yumpackage manager, so you can use the following command to install Python 3:
sudo yum install python3 -yThis command will install Python 3 and the associated tools, including
pip(Python’s package manager).
Step 4: Verify the Installation
After the installation is complete, verify that Python 3 has been installed correctly by checking the version. Run the following command to check the Python version:
python3 --versionYou should see an output similar to:
Python 3.x.xThis confirms that Python 3 has been successfully installed on your CentOS 7 system.
Step 5: Installpip
pipfor Python 3 (Optional)
pipis the package manager for Python that allows you to install additional Python packages. While
pipis often installed automatically along with Python 3, you can verify if it was installed by running:
pip3 --versionIf
pipis not installed, you can install it manually with the following command:
sudo yum install python3-pip -yOnce installed, you can use
pipto install additional Python packages:
pip3 install <package_name>Step 6: Set Python 3 as the Default (Optional)
By default, CentOS 7 uses Python 2.x as the system Python. If you’d like to make Python 3 the default version when running the
pythoncommand, you can create an alias.
To make this change, open the
.bash_profilefile for your user:
nano ~/.bash_profileThen, add the following line at the end of the file:
alias python=python3Save and exit the file (
CTRL+X, then
Y, and press
Enter). To apply the changes, reload your profile:
source ~/.bash_profileNow, when you run the
pythoncommand, it will invoke Python 3.
Step 7: Installing Additional Libraries (Optional)
If you need additional libraries or development tools, you can install them using
yum. For example, if you want to install the development tools needed for compiling Python extensions, you can run:
sudo yum groupinstall "Development Tools" -yThis will install a set of tools that can help you build and manage Python packages and extensions.
Conclusion
Installing Python 3 on CentOS 7 is a relatively simple yet essential process for modern software development. By following the steps outlined in this guide — from enabling required repositories to compiling Python from source or installing via
yum— you’ve successfully equipped your system with one of the most powerful and widely-used programming languages in the world.
Python 3 is the standard for a vast array of applications today, from web development to automation, data science, DevOps, and machine learning. Ensuring your CentOS 7 server runs the latest stable version of Python allows you to take full advantage of its continuously growing ecosystem of packages and frameworks.
If you’ve installed Python using the system package manager, keeping it updated is simple:
sudo yum update python3 -yHowever, if you’ve compiled it from source, updating will require downloading and compiling the newer version manually — a process very similar to what you’ve already done.
As a final note, consider setting up a virtual environment using venv or virtualenv for your projects. This helps isolate dependencies, avoid version conflicts, and maintain cleaner development workflows.
You are now ready to:
Run Python 3 scripts and applications
Use
pipto install third-party libraries
Create virtual environments for isolated project setups
Build, deploy, and automate tasks on your CentOS 7 server with Python 3
With Python 3 properly installed and configured, your CentOS 7 system is now fully equipped to support modern development environments. Dive into your next project with confidence — whether you’re building APIs with Flask or Django, automating server operations, or analyzing data with Pandas and NumPy.
Conclusion
Installing Python 3 on CentOS 7 is a crucial step for anyone looking to run modern applications or develop software using current libraries and frameworks. This guide walked you through enabling the required repositories, installing dependencies, downloading the source code, and compiling Python 3. With these steps completed, you now have a robust, up-to-date Python environment on a traditionally conservative operating system.
CentOS 7 doesn’t come with Python 3 by default, but with this method, you retain the system’s stability while gaining access to the flexibility and power of Python 3.x. Whether you’re running automation scripts, deploying Django/Flask apps, or using tools like Ansible, your CentOS server is now ready for the task. Remember to use python3 and pip3 explicitly in your commands, and consider creating virtual environments with venv to keep your projects isolated and manageable.
You’re now fully equipped to build, test, and deploy Python-based applications on CentOS 7 — efficiently and securely.


