CentOS is a popular Linux distribution that comes with Python 2 installed by default. However, if you want to use Python 3, you can change the default version by following a few simple steps. In this blog post, we will guide you through the process of changing the default Python version from Python 2 to Python 3 in CentOS.
Step-by-Step Guide
- Check the current Python version by running the command:
python --version
This command will display the version of Python currently installed on your system.
- Install Python 3 by running the command:
sudo yum install python3
This will install the latest version of Python 3 available in the CentOS repository.
- Check the installed Python 3 version by running the command:
python3 --version
This command will display the version of Python 3 you just installed.
- Change the symbolic link for
/usr/bin/python
to point to the newly installed Python 3 by running the command:
sudo ln -sf /usr/bin/python3 /usr/bin/python
This will set Python 3 as the default version when you run the python
command.
- Verify that Python 3 is the default version by running the command:
python --version
This command should now display the version of Python 3 you just installed.
- Update any packages that depend on Python by running the command:
sudo yum update
This will ensure that all packages that require Python are updated to use the new version.
That's it! You have successfully changed the default version of Python from Python 2 to Python 3 in CentOS.
No comments:
Post a Comment
If you have any doubts regarding the post. Please let me know.