현재 설치된 CentOS의 Python Version은 3.6인데 개발용 노트북에 설치된 3.7에 있는 calendar.nextmonth(/usr/local/lib/python3.6/calendar.py) function이 없어서 직접추가 해서 사용했으나, 이번에 새로 CentOS에 Python Version을 Upgrade하기로 했다.
1. 현재 python version 확인
[root@centOS7 ~]# python --version
Python 3.6.0
[root@centOS7 ~]# which python
/usr/bin/python
[root@centOS7 ~]# ls -al /usr/bin/python
lrwxrwxrwx 1 root root 22 May 18 2020 /usr/bin/python -> /usr/local/bin/python3
[root@centOS7 ~]# ls -al /usr/local/bin/python*
lrwxrwxrwx 1 root root 9 May 19 2020 /usr/local/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 12583478 May 19 2020 /usr/local/bin/python3.6
lrwxrwxrwx 1 root root 17 May 19 2020 /usr/local/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 12583478 May 19 2020 /usr/local/bin/python3.6m
-rwxr-xr-x 1 root root 3092 May 19 2020 /usr/local/bin/python3.6m-config
lrwxrwxrwx 1 root root 16 May 19 2020 /usr/local/bin/python3-config -> python3.6-config
2. python download
https://www.python.org/downloads/
다운로드 링크 복사하여 CentOS에서 다운로드
[root@centOS7 ~]# cd /home
[root@centOS7 home]# ls
anzinda76 Python-3.6.0 Python-3.6.0.tgz svn venv webapp
[root@centOS7 home]#
[root@centOS7 home]#
[root@centOS7 home]# wget https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tgz
[root@centOS7 home]# ls
anzinda76 Python-3.6.0 Python-3.6.0.tgz Python-3.9.12.tgz svn venv webapp
[root@centOS7 home]#
[root@centOS7 home]# tar xvf Python-3.9.12.tgz
[root@centOS7 home]# ls
anzinda76 Python-3.6.0 Python-3.6.0.tgz Python-3.9.12 Python-3.9.12.tgz svn venv webapp
3. 설치
[root@centOS7 home]# cd Python-3.9.12/
# python 인터프리터 속도 향상
[root@centOS7 Python-3.9.12]# ./configure --enable-optimizations
[root@centOS7 Python-3.9.12]# make
[root@centOS7 Python-3.9.12]# make install
4. 버전확인
[root@centOS7 home]# ls -al /usr/bin/python
lrwxrwxrwx 1 root root 22 May 18 2020 /usr/bin/python -> /usr/local/bin/python3
[root@centOS7 home]# ls -al /usr/local/bin/python*
lrwxrwxrwx 1 root root 9 May 5 01:30 /usr/local/bin/python3 -> python3.9
-rwxr-xr-x 2 root root 12583478 May 19 2020 /usr/local/bin/python3.6
lrwxrwxrwx 1 root root 17 May 19 2020 /usr/local/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 12583478 May 19 2020 /usr/local/bin/python3.6m
-rwxr-xr-x 1 root root 3092 May 19 2020 /usr/local/bin/python3.6m-config
-rwxr-xr-x 1 root root 15300793 May 5 01:29 /usr/local/bin/python3.9
-rwxr-xr-x 1 root root 3087 May 5 01:30 /usr/local/bin/python3.9-config
lrwxrwxrwx 1 root root 16 May 5 01:30 /usr/local/bin/python3-config -> python3.9-config
[root@centOS7 home]#
[root@centOS7 home]#
[root@centOS7 home]#
[root@centOS7 home]# python --version
Python 3.9.12
[root@centOS7 home]# ls -al /usr/local/lib
total 58644
drwxr-xr-x. 5 root root 97 May 5 01:41 .
drwxr-xr-x. 12 root root 4096 Aug 12 2015 ..
-r-xr-xr-x 1 root root 21533512 May 19 2020 libpython3.6m.a
-rwxr-xr-x 1 root root 38483456 May 5 01:29 libpython3.9.a
drwxr-xr-x 2 root root 133 May 5 01:30 pkgconfig
drwxr-xr-x 35 root root 8192 May 19 2020 python3.6
drwxr-xr-x 36 root root 8192 May 5 01:30 python3.9
3.10.x 버전은 compile때 자꾸 오류발생함. 왜 그런지 모르겠음.
그리고 공용 라이브라러가 python 3.9.12버전으로 Upgrade되었을뿐 현재 blog의 Virtual Environment는 여전히 python version 3.6.0 이다.