Enable Software Collections (SCL)
Software Collections, also known as SCL is a community project that allows you to build, install, and use multiple versions of software on the same system, without affecting system default packages. By enabling Software Collections you will gain access to the newer versions of programming languages and services which are not available in the core repositories.
CentOS 7 ships with Python 2.7.5 which is a critical part of the CentOS base system. SCL will allow you to install newer versions of python 3.x alongside the default python v2.7.5 so that system tools such as yum
will continue to work properly.
In order to enable SCL we need to install the CentOS SCL release file. It is part of the CentOS extras repository and can be installed by running the following command: SCL : https://wiki.centos.org/zh/AdditionalResources/Repositories/SCL
sudo yum install centos-release-scl
Installing Python 3 on CentOS 7
Now that we have access to the SCL repository we can install any Python 3.x version we need. Currently, the following Python 3 collections are available:
- Python 3.3
- Python 3.4
- Python 3.5
- Python 3.6
In this tutorial we will install Python 3.6 which is the latest version available at the time of writing. To do so type the following command on your CentOS 7 terminal:
sudo yum install rh-python36
Using Python 3
After the package rh-python36
is installed, check the Python version by typing:
python --version
You will notice that Python 2.7 is the default Python version in your current shell.
To access Python 3.6 you need to launch a new shell instance using the Software Collection scl
tool:
scl enable rh-python36 bash
What the command above does is calling the script /opt/rh/rh-python36/enable
which changes the shell environment variables.
If you check the Python version again, you’ll notice that Python 3.6 is the default version in your current shell now.
It is important to point out that Python 3.6 is set as the default Python version only in this shell session. If you exit the session or open a new session from another terminal Python 2.7 will be the default Python version.
参考:
https://linuxize.com/post/how-to-install-python-3-on-centos-7/#installing-python-3-on-centos-7
- •VMware Workstation Pro 16安装CentOS7超详细图文步骤
- •CentOS7下配置使用JumpServer 堡垒机 (图文教程)
- •CentOS安装jdk的几种方法及配置环境变量方式
- •CentOS忘记密码修改方案以及centos卡在开机登录界面,命令失效的解决方法
- •解决笔记本安装centos7后无法调节屏幕亮度
- •VMware安装CentOS 8.1(CentOS 8系列可参考)的图文详细教程
- •CentOS7 minimal 最小化安装网络设置过程
- •CentOS7下搭建JumpServer
- •CentOS安装rpm包出现冲突时的解决办法
- •Vmware下CentOS7最小化安装方式