CentOS 7에서 python3 업그레이드
테스트 환경
운영체제 버전
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
python 버전
$ python --version
Python 2.7.5
$ python3 --version
Python 3.6.8
SCL 유틸리티 설치
yum install -y centos-release-scl
python 업그레이드
python3.8 설치
yum install -y rh-python38 rh-python38-python-pip
python 버전
$ /opt/rh/rh-python38/root/usr/bin/python --version
Python 3.8.11
alternatives 확인
alternatives --display python
update-alternatives 등록
update-alternatives --install /usr/bin/python python /opt/rh/rh-python38/root/usr/bin/python3 2
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
alternatives 확인(2.7로 원복)
alternatives --display python
$ alternatives --display python
python - 상태가 수동입니다.
현재 /usr/bin/python2.7로 링크되어 있습니다
/opt/rh/rh-python38/root/usr/bin/python3 - priority 1
/usr/bin/python2.7 - priority 2
현재 '최고' 버전은 /usr/bin/python2.7입니다.
python3.8로 path를 변경하고 yum 명령을 실행하였으나 에러가 발생하여 원복하였다 ㅠㅠ
update-alternatives python3.8
update-alternatives --config python
$ update-alternatives --config python
2 개의 프로그램이 'python'를 제공합니다.
선택 명령
-----------------------------------------------
1 /opt/rh/rh-python38/root/usr/bin/python3
*+ 2 /usr/bin/python2.7
현재 선택[+]을 유지하려면 엔터키를 누르고, 아니면 선택 번호를 입력하십시오:1
alternatives 확인
alternatives --display python
$ alternatives --display python
python - 상태가 수동입니다.
현재 /opt/rh/rh-python38/root/usr/bin/python3로 링크되어 있습니다
/opt/rh/rh-python38/root/usr/bin/python3 - priority 1
/usr/bin/python2.7 - priority 2
현재 '최고' 버전은 /usr/bin/python2.7입니다.
python 버전 확인
python --version
$ python --version
Python 3.8.11
yum 실행 시 에러
$ yum
File "/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
'리눅스' 카테고리의 다른 글
| [draft] RabbitMQ에서 관리자 계정을 초기화하고 재설정하는 방법 (0) | 2025.10.30 |
|---|---|
| [draft] 파이션 코드를 사용한 RabbitMQ 메시지 큐의 간단한 테스트 (0) | 2025.10.30 |
| [draft] RabbitMQ를 설치하고 테스트하는 방법 (0) | 2025.10.30 |
| [draft] 우분투에 RabbitMQ를 설치하는 방법 (0) | 2025.10.30 |
| [draft] CentOS 7 RabbitMQ 설치 방법 (0) | 2025.10.30 |