728x90
반응형
SMALL
centOS 7 리눅스에는 기본적으로 파이썬 2.7이 설치되어 있다.
아래 명령어로 파이썬 버전을 확인할 수 있다.
python --version Python 2.7.5이를 최신버전으로 바꿔서 설치해본다.
루트계정으로 로그인해서 아래 명령어 실행한다.
이는 파이썬 설치에 필요한 각종 플로그인을 다운받는다.
gcc는 gnu 컴파일러 모음을 의미한다.
openssl-devel은 웹브라우저와 서버 간의 통신을 암호화하는 오픈소스 라이브러리이다.
bzip2-devel은 압축프로그램중 하나이다
libffi-devel은 인터프리터언어와 컴파일 언어 연결해주는 라이브러리이다.
뒤에 -devel은 컴파일을 위한 라이브러리 패키지이다.
yum install gcc openssl-devel bzip2-devel libffi-devel -y그리고 아래 파이썬 사이트에가서 최신버전을 설치한다.
//www.python.org/downloads/
아래 네모부분 링크복사한다.
아래 명령어 실행
wget //www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz그리고 압축을 풀어준다.
tar -xvf Python-3.9.5.tgz이제 파이썬 디렉토리로 들어가서 컴파일을 해준다.
cd Python-3.9.5/ ./configure --enable-optimizations컴파일을 마쳤으면 설치한다. 약 3분정도 걸리는 것 같다.
make altinstall파이썬 3.9 바이너리 파일이 어디있는지 확인한다.
그리고 bash파일에 파이썬 별칭을 만든다.
vi /root/.bashrcsource명령어로 적용시킨다.
source /root/.bashrc이제 잘 적용되었는지 확인하기 위해 파이썬 버전을 출력해본다.
python -V Python 3.9.5추가적으로 pip3를 설치하는 과정은 아래 글 참고~
//earthconquest.tistory.com/224?category=888283
[Linux] Linux CentOS 7에 파이썬 pip3 설치하기
pip는 파이썬으로 작성된 패키지 라이브러리들을 관리해주는 시스템이다. 만약 yum이 안될 경우 업데이트를 해준다. [root@localhost ~]# yum update [root@localhost ~]# yum install epel-release //pip를 설치..
earthconquest.tistory.com
728x90
반응형
LIST
저작자표시동일조건
'데이터 엔지니어링 정복 > Python' 카테고리의 다른 글
2021.09.02 |
2021.08.31 |
2021.05.17 |
2021.05.17 |
2021.05.17 |
I'm trying to install Python 3.9 an EC2 instance that uses Amazon Linux 2. I tried following this guide: //computingforgeeks.com/install-latest-python-on-centos-linux/, and I was able to install Python3.9 manually on the EC2 instance by SSH'ing in and running the commands. I'm now trying to setup the EC2 instance with a UserData script that calls some CloudFormationInit scripts to install dependencies, including Python 3.9, and my script is failing.
Here's part of the script that I'm using to install Python 3.9:
const installPythonString = ` #!/bin/bash sudo amazon-linux-extras install -y epel sudo yum -y update sudo yum groupinstall "Development Tools" -y sudo yum install openssl-devel libffi-devel bzip2-devel -y gcc --version sudo yum install wget -y sudo mkdir -p /opt/python3.9/ sudo chown -R $USER:$USER /opt/python3.9/ wget //www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz -P /opt/python3.9 cd /opt/python3.9/ tar xvf Python-3.9.9.tgz whoami sudo chown -R $USER:$USER Python-3.9.9 cd Python-3.9.9/ ls -al pwd ./configure --enable-optimizations sudo make altinstall python3.9 --version pip3.9 --version `; init.addConfig('install_python39', new ec2.InitConfig([ ec2.InitFile.fromString('/opt/install_python39.sh', installPythonString, { mode: '000755', owner: 'root', group: 'root', }), ec2.InitCommand.shellCommand('sudo sh install_python39.sh', { cwd: '/opt', key: 'install_python39', }), ]))I'm getting the following errors when trying to start up the EC2 instance:
Python build finished successfully! ... WARNING: The script pip3.9 is installed in '/usr/local/bin' which is not on PATH. install_python39.sh: line 21: python3.9: command not found install_python39.sh: line 22: pip3.9: command not foundIs there an easier way to install Python 3.9 on Amazon Linux 2 using CloudFormationInit?