개발/python

python3.11 설치 방법 (ubuntu 20.04 기준)

나한순간에 2023. 5. 14. 12:22

우분투 20.04에 기본제공하는 python3.8 보다 python3.11이 속도적 측면으로 많이 개선되었다는 말을 들어서 한번 설치를 해보았다.

https://betterdatascience.com/python-310-vs-python-311/

 

Python is About to Become 64% Faster - Python 3.10 vs. Python 3.11 Benchmark | Better Data Science

Let’s compare Python 3.10 vs. Python 3.11 in an extensive benchmark test. Spoiler alert: Python 3.11 is up to 64% faster!

betterdatascience.com

기본적으로 우분투의 경우 ppa를 추가하여 하는방법도 있지만, 현재 내가 다니는 회사의 환경에서는 뭔가 개인이 만든 ppa 추가를 좀 꺼려하는 경향이 없지 않아 있다.

그래서 ppa추가가 아닌 소스로 설치를 하는 방법을 정리차 기록한다.

 

[아래는 기본적으로 소스컴파일 하는데 필요한 패키지]

root ~ # apt-get install build-essential checkinstall libbz2-dev libc6-dev libdb-dev libffi-dev libgdbm-compat-dev libgdbm-dev liblzma-dev libncurses libncurses-dev libncurses5-dev libncursesw5-dev libnss3-dev libreadline-dev libreadline-gplv2-dev libsqlite3-dev libssl-dev libssl1.1 openssl openssl-dev pkg-config python-apt sqlite3 tcl8.6-dev tk-dev tk8.6-dev uuid-dev wget zlib1g-dev

[파이썬 소스 다운로드/소스컴파일]

root ~ # wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tar.xz

root ~ # tar xvf Python-3.11.3.tar.xz

root ~ # cd Python-3.11.3

root ~ # ./configure --enable-optimizations
# -> 필요한 종속성이 충족되는지 확인하고 위 명령을 사용하여 바이너리를 최적화한다.

root ~ # make -j $(nproc)
# -> 시스템에서 사용 가능한 코어 수를 제공하기 위해 -j를 사용한다.
# -> 이렇게 하면 빌드 프로세스가 더 빨라 진다.
# -> 이때 잘 봐야한다. 특정 모듈관련되서 에러가 난다면, 반드시 해결하고 가야만한다.
# -> 예를들면 ssl 관련에러가 나는데, 무시하고 install하게 되면 추후에 ssl관련 모듈 못쓴다.

root ~ # make altinstall

참조링크: https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux/

[동작 잘하는지 테스트]

root ~ # python3.11 -m venv production
root ~ # cd production/
root ~/production # ll
total 24
drwxr-xr-x  5 root root 4096 May 14 12:23 ./
drwx------ 14 root root 4096 May 14 12:23 ../
drwxr-xr-x  2 root root 4096 May 14 12:23 bin/
drwxr-xr-x  3 root root 4096 May 14 12:23 include/
drwxr-xr-x  3 root root 4096 May 14 12:23 lib/
lrwxrwxrwx  1 root root    3 May 14 12:23 lib64 -> lib/
-rw-r--r--  1 root root  176 May 14 12:23 pyvenv.cfg
root ~/production # source bin/activate
(production) root ~/production # python
Python 3.11.3 (main, May 13 2023, 10:10:33) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

'개발 > python' 카테고리의 다른 글

pyenv 설정을 해보자  (1) 2023.10.22
파이썬 인터프리터 자동완성  (0) 2021.03.01