의식여행
[CentOS7] Python 3.7 설치 및 설정 방법 본문
Overview
이번 포스팅은 최근 개발언어로서 큰 화두가 되고 있는 Python 3.7버전을 설치하고 구성하는 방법을 다루도록 하겠습니다.
Python3.7 설치 및 설정 방법
1. https://www.python.org/downloads/ 접속하여 원하는 버전 다운로드
■ 필요패키지 : zlib, zlib-devel, libffi-devel
→ yum -y install zlib zlib-devel libffi-devel
※ 미설치시, "zipimport.zipimporterror" 및 "ImportError : 'No Module name_ctypes' Error발생 ※
■ 설치 명령
1) tar xvzf Python-3.7.0.tgz
2) cd Python-3.7.0.tgz
3) ./configure --prefix=/tmp/python3.7 --enable-optimizations
4) make altinstall
5) ln -s /tmp/python3.7/bin/python3.7 /usr/bin/python3.7
6) python3.7
■ pip 설치
-pip란, 파이썬으로 작성된 패키지 소프트웨어 설치ㆍ관리하는 패키지 관리 시스템
-Python3.7 설치 시 pip-10.0.1 자동 설치
■ pip 사용방법
-python3.7 -m pip <command> [options] 형태로 사용 가능
※ 인터넷 사용이 불가한경우, https://pypi.org에 대한 접근제어 설정 필요※
pip SSL 관련 오류 해결 방법
■ SSL 관련 오류
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
■ SSL 관련 오류 원인
-openssl openssl-devel 패키지가 설치되어 있지 않을 때 발생
■ SSL 관련 오류 해결 방법
1) yum -y install openssl openssl-devel
2) vi Python3.7/Modules/Setup.dist (파이썬 소스 압축 해제 파일)
3) 아래 내용 주석 해제
- _socket socketmodule.c
- SSL=/usr/local/ssl
- _ssl _ssl.c \
DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
-./configure --prefix=/tmp/python3.7 --enable-optimiazations
-make altinstall
감사합니다.