[Python] 버전 3.8 CentOS 7에 설치

[root@nas ~]# yum -y install centos-release-scl-rh centos-release-scl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: ftp.riken.jp
 * extras: mirror.kakao.com
 * remi-safe: ftp.riken.jp
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl.noarch 0:2-3.el7.centos will be installed
---> Package centos-release-scl-rh.noarch 0:2-3.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
 Package                                             Arch                                 Version                                        Repository                            Size
====================================================================================================================================================================================
Installing:
 centos-release-scl                                  noarch                               2-3.el7.centos                                 extras                                12 k
 centos-release-scl-rh                               noarch                               2-3.el7.centos                                 extras                                12 k

Transaction Summary
====================================================================================================================================================================================
Install  2 Packages

Total download size: 24 k
Installed size: 39 k
Downloading packages:
(1/2): centos-release-scl-2-3.el7.centos.noarch.rpm                                                                                                          |  12 kB  00:00:00
(2/2): centos-release-scl-rh-2-3.el7.centos.noarch.rpm                                                                                                       |  12 kB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                85 kB/s |  24 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                      1/2
  Installing : centos-release-scl-2-3.el7.centos.noarch                                                                                                                         2/2
  Verifying  : centos-release-scl-2-3.el7.centos.noarch                                                                                                                         1/2
  Verifying  : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                      2/2

Installed:
  centos-release-scl.noarch 0:2-3.el7.centos                                              centos-release-scl-rh.noarch 0:2-3.el7.centos

Complete!

yum scl repository 설치

 

[root@nas ~]# yum --enablerepo=centos-sclo-rh -y install rh-python38
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * centos-sclo-rh: mirror.kakao.com
 * centos-sclo-sclo: mirror.kakao.com
 * epel: ftp.riken.jp
 * extras: mirror.kakao.com
 * remi-safe: ftp.riken.jp
 * updates: mirror.kakao.com
centos-sclo-rh                                                                                                                                               | 3.0 kB  00:00:00
centos-sclo-sclo                                                                                                                                             | 3.0 kB  00:00:00
(1/2): centos-sclo-sclo/x86_64/primary_db                                                                                                                    | 300 kB  00:00:00
(2/2): centos-sclo-rh/x86_64/primary_db                                                                                                                      | 3.3 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package rh-python38.x86_64 0:2.0-4.el7 will be installed
--> Processing Dependency: rh-python38-runtime for package: rh-python38-2.0-4.el7.x86_64
--> Processing Dependency: rh-python38-python for package: rh-python38-2.0-4.el7.x86_64
--> Processing Dependency: rh-python38-python-pip for package: rh-python38-2.0-4.el7.x86_64
--> Processing Dependency: rh-python38-python-setuptools for package: rh-python38-2.0-4.el7.x86_64
--> Running transaction check
---> Package rh-python38-python.x86_64 0:3.8.11-2.el7 will be installed
--> Processing Dependency: rh-python38-python-libs(x86-64) = 3.8.11-2.el7 for package: rh-python38-python-3.8.11-2.el7.x86_64
--> Processing Dependency: libpython3.8.so.rh-python38-1.0()(64bit) for package: rh-python38-python-3.8.11-2.el7.x86_64
---> Package rh-python38-python-pip.noarch 0:19.3.1-2.el7 will be installed
---> Package rh-python38-python-setuptools.noarch 0:41.6.0-7.el7 will be installed
---> Package rh-python38-runtime.x86_64 0:2.0-4.el7 will be installed
--> Running transaction check
---> Package rh-python38-python-libs.x86_64 0:3.8.11-2.el7 will be installed
--> Processing Dependency: rh-python38-python-pip-wheel for package: rh-python38-python-libs-3.8.11-2.el7.x86_64
--> Processing Dependency: rh-python38-python-setuptools-wheel for package: rh-python38-python-libs-3.8.11-2.el7.x86_64
--> Running transaction check
---> Package rh-python38-python-pip-wheel.noarch 0:19.3.1-2.el7 will be installed
---> Package rh-python38-python-setuptools-wheel.noarch 0:41.6.0-7.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
 Package                                                      Arch                            Version                                 Repository                               Size
====================================================================================================================================================================================
Installing:
 rh-python38                                                  x86_64                          2.0-4.el7                               centos-sclo-rh                          2.8 k
Installing for dependencies:
 rh-python38-python                                           x86_64                          3.8.11-2.el7                            centos-sclo-rh                           71 k
 rh-python38-python-libs                                      x86_64                          3.8.11-2.el7                            centos-sclo-rh                          7.7 M
 rh-python38-python-pip                                       noarch                          19.3.1-2.el7                            centos-sclo-rh                          1.7 M
 rh-python38-python-pip-wheel                                 noarch                          19.3.1-2.el7                            centos-sclo-rh                          1.2 M
 rh-python38-python-setuptools                                noarch                          41.6.0-7.el7                            centos-sclo-rh                          636 k
 rh-python38-python-setuptools-wheel                          noarch                          41.6.0-7.el7                            centos-sclo-rh                          299 k
 rh-python38-runtime                                          x86_64                          2.0-4.el7                               centos-sclo-rh                          1.1 M

Transaction Summary
====================================================================================================================================================================================
Install  1 Package (+7 Dependent packages)

Total download size: 13 M
Installed size: 49 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/rh-python38-python-3.8.11-2.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID f2ee9d55: NOKEY
Public key for rh-python38-python-3.8.11-2.el7.x86_64.rpm is not installed
(1/8): rh-python38-python-3.8.11-2.el7.x86_64.rpm                                                                                                            |  71 kB  00:00:00
(2/8): rh-python38-2.0-4.el7.x86_64.rpm                                                                                                                      | 2.8 kB  00:00:00
(3/8): rh-python38-python-pip-19.3.1-2.el7.noarch.rpm                                                                                                        | 1.7 MB  00:00:00
(4/8): rh-python38-python-pip-wheel-19.3.1-2.el7.noarch.rpm                                                                                                  | 1.2 MB  00:00:00
(5/8): rh-python38-python-libs-3.8.11-2.el7.x86_64.rpm                                                                                                       | 7.7 MB  00:00:00
(6/8): rh-python38-python-setuptools-41.6.0-7.el7.noarch.rpm                                                                                                 | 636 kB  00:00:00
(7/8): rh-python38-python-setuptools-wheel-41.6.0-7.el7.noarch.rpm                                                                                           | 299 kB  00:00:00
(8/8): rh-python38-runtime-2.0-4.el7.x86_64.rpm                                                                                                              | 1.1 MB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                31 MB/s |  13 MB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Importing GPG key 0xF2EE9D55:
 Userid     : "CentOS SoftwareCollections SIG (https://wiki.centos.org/SpecialInterestGroup/SCLo) <security@centos.org>"
 Fingerprint: c4db d535 b1fb ba14 f8ba 64a8 4eb8 4e71 f2ee 9d55
 Package    : centos-release-scl-rh-2-3.el7.centos.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-python38-runtime-2.0-4.el7.x86_64                                                                                                                             1/8
  Installing : rh-python38-python-setuptools-wheel-41.6.0-7.el7.noarch                                                                                                          2/8
  Installing : rh-python38-python-pip-wheel-19.3.1-2.el7.noarch                                                                                                                 3/8
  Installing : rh-python38-python-libs-3.8.11-2.el7.x86_64                                                                                                                      4/8
  Installing : rh-python38-python-setuptools-41.6.0-7.el7.noarch                                                                                                                5/8
  Installing : rh-python38-python-3.8.11-2.el7.x86_64                                                                                                                           6/8
  Installing : rh-python38-python-pip-19.3.1-2.el7.noarch                                                                                                                       7/8
  Installing : rh-python38-2.0-4.el7.x86_64                                                                                                                                     8/8
  Verifying  : rh-python38-2.0-4.el7.x86_64                                                                                                                                     1/8
  Verifying  : rh-python38-python-3.8.11-2.el7.x86_64                                                                                                                           2/8
  Verifying  : rh-python38-python-setuptools-wheel-41.6.0-7.el7.noarch                                                                                                          3/8
  Verifying  : rh-python38-python-pip-wheel-19.3.1-2.el7.noarch                                                                                                                 4/8
  Verifying  : rh-python38-python-libs-3.8.11-2.el7.x86_64                                                                                                                      5/8
  Verifying  : rh-python38-python-pip-19.3.1-2.el7.noarch                                                                                                                       6/8
  Verifying  : rh-python38-python-setuptools-41.6.0-7.el7.noarch                                                                                                                7/8
  Verifying  : rh-python38-runtime-2.0-4.el7.x86_64                                                                                                                             8/8

Installed:
  rh-python38.x86_64 0:2.0-4.el7

Dependency Installed:
  rh-python38-python.x86_64 0:3.8.11-2.el7                 rh-python38-python-libs.x86_64 0:3.8.11-2.el7             rh-python38-python-pip.noarch 0:19.3.1-2.el7
  rh-python38-python-pip-wheel.noarch 0:19.3.1-2.el7       rh-python38-python-setuptools.noarch 0:41.6.0-7.el7       rh-python38-python-setuptools-wheel.noarch 0:41.6.0-7.el7
  rh-python38-runtime.x86_64 0:2.0-4.el7

Complete!

Python 3.8 설치

 

[root@nas ~]# scl enable rh-python38 bash

Python 3.8 사용할 수 있도록 명령어 실행

 

[root@nas ~]# python -V
Python 3.8.11

python 버전 확인

 

[root@nas ~]# which python
/opt/rh/rh-python38/root/usr/bin/python

python 위치 확인

 

[root@nas ~]# vi /etc/profile.d/python38.sh

SSH 로그아웃하면 Python 3.8을 바로 사용할 수 없기 때문에 자동으로 사용할 수 있도록 스크립트 편집

 

source /opt/rh/rh-python38/enable
export X_SCLS="`scl enable rh-python38 'echo $X_SCLS'`"

자동으로 사용할 수 있도록 스크립트 추가

 

출처: Initial Settings : Add Repositories, Install Python 3.8