본문 바로가기
프로그래밍

[CentOS7] 파이썬 3점대 설치

by choihyuunmin 2021. 5. 14.

centos7의 파이썬 기본 버전은 2점대이다. 파이썬 3점대는 직접 설치해줘야한다.

 

 

 

-- openssl 설치
sudo yum -y install gcc openssl-devel bzip2-devel xz-devel

 

-- wget 설치 (root) --> python 3.6.8
yum install wget
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz

 

-- 압축해제 후 설치 디렉터리로 이동

tar xzf Python-3.6.8.tgz
cd Python-3.6.8

 

-- 컴파일

yum install sqlite-devel -y
 
./configure --enable-optimizations --enable-loadable-sqlite-extensions
make
make altinstall

#pip 설치
[root@localhost Python-3.6.8]# which pip
/usr/bin/which: no pip in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
 
[root@localhost Python-3.6.8]# sudo ln -sfn /usr/local/bin/python3.6 /usr/bin/python3
[root@localhost Python-3.6.8]# curl -k -O https://bootstrap.pypa.io/get-pip.py

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1882k  100 1882k    0     0   604k      0  0:00:03  0:00:03 --:--:--  739k

[root@localhost Python-3.6.8]# python3 get-pip.py
Collecting pip
  Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 660 kB/s
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, pip
  Attempting uninstall: pip
    Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-21.0.1 wheel-0.36.2
[root@localhost Python-3.6.8]# which pip
/usr/local/bin/pip
[root@localhost Python-3.6.8]# pip -V
pip 21.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
[root@localhost Python-3.6.8]#