Centos

CentOS 7.7 和 Python

  • January 5, 2020

我讀過 CentOS 7.7 在CentOS Linux 7.7 上將 Python 升級到 3.6 版,這裡是如何更新它

誰能解釋我為什麼在我的 Centos 7.7 伺服器中我有 Python 2.7.5,它是 EOL 而不是 Python 3.6 並且 yum 不提供升級到 Python 3.6 的可能性?

[root@cpanel ~]# hostnamectl
  Static hostname: hidden(myserver hostname)
        Icon name: computer-server
          Chassis: server
       Machine ID: ade4e1c7a3534397a3f75bdf9eee8e4d
          Boot ID: 6870183871774c68a23a0c04230d1408
 Operating System: CentOS Linux 7 (Core)
      CPE OS Name: cpe:/o:centos:centos:7
           Kernel: Linux 3.10.0-514.26.2.el7.x86_64
     Architecture: x86-64
[root@cpanel ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@cpanel ~]# python -V
Python 2.7.5
# cat /etc/yum.conf 
[main]
exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* nsd* p0f php* proftpd* pure-ftpd* spamassassin* squirrelmail*
tolerant=1
errorlevel=1
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
[root@cpanel ~]# yum upgrade python
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 104.254.183.20
* cpanel-addons-production-feed: 104.254.183.20
* cpanel-plugins: 104.254.183.20
* base: mirror.tzulo.com
* epel: mirror.steadfastnet.com
* extras: mirror.den01.meanservers.net
* updates: mirror.sesp.northwestern.edu
No packages marked for update

包中提供了 Python 3 python3

yum install python3

解釋器也是python3python仍將執行 Python 2 解釋器。

PSF 已將 Python 2 宣佈為 EOL,但Red Hat 仍然在 RHEL 中提供對 Python 2 的支持,CentOS 應該會繼續受益於這種支持。

來自 CentOS 的 Python 2.7.5 實際上並不是 EOL,因為 CentOS 將在 CentOS 7 的整個生命週期內支持它。Red Hat Enterprise Linux 7 附帶的 Python 2.7.5 也是如此。

如果你想獲得 Python 3,那麼你可以安裝它:

yum install python3

你也可以從 CentOS Software Collections Repo 獲得它:

yum install centos-release-scl

然後,您可以使用以下命令安裝 Python 3 到 3.6 的任何顛覆:

yum install rh-python33
yum install rh-python34
yum install rh-python35
yum install rh-python36

引用自:https://unix.stackexchange.com/questions/560318