分享好友 系统运维首页 频道列表

CentOS 7 - 安装Python 3

Centos  2023-02-10 03:010

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/

https://www.centos.bz/2018/07/centos-7-%E5%AE%89%E8%A3%85-python-3-7/

查看更多关于【Centos】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
centos6下同时安装python2和python3
#build-essential compile packagesyum groupinstall "Development Tools"yum install openssl-develyum install zlib-develyum install make gcc gcc-c++ kernel-develhttp://unix.stackexchange.com/questions/291737/zipimport-zipimporterror-cant-decomp

0评论2023-02-10677

CentOS下查看文件和文件夹大小 linux查看文件夹大小
当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。  df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。  df可以查

0评论2023-02-10731

centos7 rc.local脚本执行不成功
腾讯云 centos7   配置文件/etc/rc.local的内容如下:#!/bin/sh#secu_agent init monitor, install at Thu Aug 3 11:19:41 CST 2017/usr/local/sa/agent/init_check.sh/dev/null 21/usr/sbin/ntpdate ntpupdate.tencentyun.com /dev/null 21 /usr/local/qclo

0评论2023-02-10442

如何在centos7启动时自动挂载硬盘
在/etc/rc.local中加入如下的语句,这样就不用每次重启后手动挂载了(后面挂载的目录根据自己的需求而定):mount  /dev/sdb1 /usr/sharedfiles/sdbmount  /dev/sdc1 /usr/sharedfiles/sdcmount  /dev/sdb1 /root/sdbmount  /dev/sdc1 /root/sdc注意:可以

0评论2023-02-10535

centos7.2 开启防火墙
开启防火墙当我们修改了某些配置之后(尤其是配置文件的修改),firewall并不会立即生效。可以通过两种方式来激活最新配置 systemctl restart firewalld 和 firewall-cmd --reload 两种方式,前一种是重启firewalld服务,建议使用后一种“重载配置文件”

0评论2023-02-10997

CentOS7 安装 Python3.8后 pip 安装报错
[root@localhost Python-3.8.0]# pip install bs4Collecting bs4Using cached https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gzERROR: Command errored out with exit status

0评论2023-02-10961

[转]How to install PHP 5.3 on CentOS
在DIAHosting买了一个VPS,自带PHP5.1.6.我想安装wordpress,但是由于版本比较新,要求PHP也要是5.2以上的,于是我就安装了PHP5.3.20--------------------------------------------------------------------------------------------------------------------

0评论2023-02-10997

外部访问docker内部容器centos的http服务
1.创建容器docker run -d -it -h dd -p 5000 --name bbbbb centosdd 是用户名 --name 后面是容器名字2.在我们开始安装Nginx及其他所需软件之前先安装一些前提软yum install python-setuptools yum -y install epel-release yum install python-pip pip instal

0评论2023-02-10480

Centos7安装yum命令 centos8如何安装yum
步骤如下http://mirrors.163.com/centos/7/os/x86_64/Packages/到上面这个网站去下载如下RPM包(为版本号,根据最新的自己替换即可)python-iniparse-.noarch.rpmyum-metadata-parser-.x86_64.rpmyum-.centos.noarch.rpmyum-plugin-fastestmirror-*.noarch.rp

0评论2023-02-10760

centos清除历史命令
1、rm -f /root/.bash_profile  历史命令记录在此文件2、history -c   清除缓存会话退出后重新连接输入history可以看到历史命令清空了。两条命令的顺序不能乱

0评论2023-02-09473

更多推荐