728x90
반응형

Centos7 설치시 파이썬 버전은 Python 2.7 버전이  Default 설치 됩니다. 

Python3.7 버전 설치 하는 방법에 대해 알아 보겠습니다. 

 

파이썬 다운로드

아래 ftp 경로에 파이썬 여러버전이 업로드 되어 있습니다. 

사용하고자 하는 버전을 확인 합니다. 

https://www.python.org/ftp/python/

 

Index of /ftp/python/

 

www.python.org

 

#설치 경로 이동 
cd /usr/src/

#파이썬 다운로드 
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

#파이썬 압축해제

필수 팩키지 리스트

#필수 설치 팩키지 확인
yum list gcc openssl-devel bzip2-devel libffi-devel

#필수 팩키지 설치 
yum install -y list gcc openssl-devel bzip2-devel libffi-devel

파이썬 설치

 #파이썬 경로 이동 
 cd Python-3.7.1/
 
#파이썬 환경 설정 
 ./configure --enable-optimizations

#설치
make altinstall
  • 정상설치 확인
Looking in links: /tmp/tmp6l2a8r7l
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
[root@centos7:/usr/src/Python-3.7.1]$ 

 

파이썬 버전 및 python3.7 환경 설정

설치 후 버전 확인을 하면 여전히 2.7 버전으로 표기 됩니다. 

링크 생성후 범용 적으로 사용 하도록 설정해 줍니다. 

 

[root@centos7:/usr/src/Python-3.7.1]$ python -V
Python 2.7.5
[root@centos7:/usr/src/Python-3.7.1]$ /usr/src/Python-3.7.1/python -V
Python 3.7.1
#bin 경로 이동 
cd /usr/bin
#링크 생성 
ln -s /usr/src/Python-3.7.1/python python3

#profile alias 설정
vi /etc/profile

alias python="python3"

#profile 적용 
. /etc/profile
  • 환경 설정 변경후 설치 버전 재 확인 
[root@centos7:/root]$ python -V
Python 3.7.1

 

728x90
반응형

+ Recent posts