티스토리 뷰

Study/System

[centos7] python 설치

pursh 2023. 1. 26. 00:32

* 참조: https://www.liquidweb.com/kb/how-to-install-python-3-on-centos-7/

* 운영체제: Centos 2207-02

* Python 버전: v3.11.1

 

* CentOS Minimal 로 설치

 

* yum으로 패키지 설치

[localhost /#] yum install -y gcc openssl-devel bzip2-devel libffi-devel

* python 3.11.1 업로드 및 설치

[localhost /#] cd /var/tmp
[localhost /#] tar zxf Python-3.11.1.tgz
[localhost /#] cd Python-3.11
[localhost /#] ./configure --enable-optimizations
[localhost /#]
[localhost /#] grep .PHONY Makefile
.PHONY=coverage coverage-lcov coverage-report
.PHONY=clinic
.PHONY: wasm_stdlib
.PHONY: regen-test-frozenmain
.PHONY: regen-re
.PHONY: regen-frozen
.PHONY: regen-deepfreeze
.PHONY: regen-importlib
.PHONY: regen-global-objects
.PHONY: regen-pegen-metaparser
.PHONY: regen-pegen
.PHONY=regen-ast
.PHONY: regen-opcode
.PHONY: regen-token
.PHONY: regen-keyword
.PHONY: regen-stdlib-module-names
.PHONY: regen-opcode-targets
.PHONY: regen-typeslots
.PHONY: test testall testuniversal buildbottest pythoninfo
.PHONY: multisslcompile multissltest
.PHONY: autoconf
.PHONY: regen-configure
.PHONY: update-config
.PHONY: all build_all build_wasm sharedmods check-clean-src oldsharedmods test quicktest
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
.PHONY: clean-retain-profile profile-removal run_profile_task
.PHONY: build_all_generate_profile build_all_merge_profile
.PHONY: gdbhooks
[localhost /#] 
[localhost /#] make altinstall

 

* alias 추가

# ~/.bashrc

alias python='/usr/local/bin/python3.11'

 

 

################################################################################

################################################################################

Source Installation

Installing Python 3 via the Yum package manager is by far the simplest way to get the job done. However, in some cases, you might want to have the most recent version of Python available and that’s where a source installation can come in handy.

 

Step 1: Setup the Environment

In order to install Python 3 from source, we are going to need to ensure that some prerequisite packages are installed on our system.

[root@centos7 ~]# yum install gcc openssl-devel bzip2-devel libffi-devel -y
 

Step 2: Download Python

Next, we need to grab the version of Python we want. The following command will pull down the latest stable version of Python 3.8 as of the writing of this article.

[root@centos7 ~]# curl -O https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
 

Now we need to extract the file.

[root@centos7 ~]# tar -xzf Python-3.8.1.tgz
 

Step 3: Install Python 3

Now that it’s extracted, let’s change into the resultant directory.

[root@centos7 ~]# cd Python-3.8.1/

Next, we need to prepare to compile Python from source.

[root@centos7 Python-3.8.1]# ./configure --enable-optimizations

Finally, we are going to use the following command to finish off the installation, without replacing the default system Python on our system.

[root@centos7 Python-3.8.1]# make altinstall

Compiling code from source takes a little while, but once that’s finished, we can test out our new Python 3 version by running the following command.

[root@centos7 Python-3.8.1]# python3.8

Much like before when we installed Python 3.6 via Yum, we are dropped into a Python shell that outputs the version we are currently using.

Python 3.8.1 (default, Dec 27 2019, 17:12:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
 

'Study > System' 카테고리의 다른 글

[Ubuntu] rc-local 서비스 활성화  (0) 2023.05.25
[Linux] bash history에 Timestamp 남기기  (0) 2023.01.28
Windows 10 cmd 창 안 열릴 때  (0) 2022.05.27
Linux에 static route 추가하기  (0) 2022.01.06
MAN Page - pam_tally2  (0) 2019.07.19
댓글