Linux,Unix,BSD

ubuntu 20.04에 python 3.10 설치하기

채윤아빠 2021. 5. 6. 19:32
728x90
반응형

개요

ubuntu 20.04에 설치되는 python 버전은 다음과 같이 3.8 입니다.

$ python3 --version
Python 3.8.10

파이썬(python) 최신 3.10을 설치하는 방법을 정리하여 둡니다.


python 3.10 설치

파이썬(python) 최신 3.10을 설치하기 위해서는 "ppa:deadsnakes/ppa" 패키지 저장소를 신규 등록해 주어야 합니다. 이를 위하여 다음과 같은 패키지 관리 도구를 설치합니다.

~$ sudo apt install software-properties-common -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
software-properties-common is already the newest version (0.99.9.8).
software-properties-common set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.

"ppa:deadsnakes/ppa" 패키지 저장소를 신규 등록합니다.

$ sudo add-apt-repository ppa:deadsnakes/ppa -y
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease [18.1 kB]
Hit:3 http://kr.archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:5 http://kr.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:6 http://kr.archive.ubuntu.com/ubuntu focal-backports InRelease
Get:7 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main i386 Packages [11.8 kB]
Get:8 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages [22.5 kB]
Get:9 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main Translation-en [5,204 B]
Fetched 57.6 kB in 3s (19.5 kB/s)
Reading package lists... Done

다음과 같이 파이썬(python) 3.10을 설치합니다.

$ sudo apt install python3.10
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpython3.10-minimal libpython3.10-stdlib python3.10-minimal
Suggested packages:
  python3.10-venv binfmt-support
The following NEW packages will be installed:
  libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-minimal
0 upgraded, 4 newly installed, 0 to remove and 40 not upgraded.
Need to get 5,171 kB of archives.
After this operation, 20.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-minimal amd64 3.10.4-1+focal2 [820 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-minimal amd64 3.10.4-1+focal2 [2,073 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-stdlib amd64 3.10.4-1+focal2 [1,746 kB]
Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10 amd64 3.10.4-1+focal2 [532 kB]
Fetched 5,171 kB in 8s (633 kB/s)
Selecting previously unselected package libpython3.10-minimal:amd64.
(Reading database ... 225217 files and directories currently installed.)
Preparing to unpack .../libpython3.10-minimal_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10-minimal.
Preparing to unpack .../python3.10-minimal_3.10.4-1+focal2_amd64.deb ...
Unpacking python3.10-minimal (3.10.4-1+focal2) ...
Selecting previously unselected package libpython3.10-stdlib:amd64.
Preparing to unpack .../libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10.
Preparing to unpack .../python3.10_3.10.4-1+focal2_amd64.deb ...
Unpacking python3.10 (3.10.4-1+focal2) ...
Setting up libpython3.10-minimal:amd64 (3.10.4-1+focal2) ...
Setting up python3.10-minimal (3.10.4-1+focal2) ...
Setting up libpython3.10-stdlib:amd64 (3.10.4-1+focal2) ...
Setting up python3.10 (3.10.4-1+focal2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...

파이썬 가상환경이 필요하면 "python3.10-venv" 패키지를 설치합니다.

$ sudo apt install python3.10-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  python3.10-distutils python3.10-lib2to3
The following NEW packages will be installed:
  python3.10-distutils python3.10-lib2to3 python3.10-venv
0 upgraded, 3 newly installed, 0 to remove and 40 not upgraded.
Need to get 3,046 kB of archives.
After this operation, 4,180 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-lib2to3 all 3.10.4-1+focal2 [125 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-distutils all 3.10.4-1+focal2 [187 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-venv amd64 3.10.4-1+focal2 [2,734 kB]
Fetched 3,046 kB in 5s (611 kB/s)
Selecting previously unselected package python3.10-lib2to3.
(Reading database ... 225869 files and directories currently installed.)
Preparing to unpack .../python3.10-lib2to3_3.10.4-1+focal2_all.deb ...
Unpacking python3.10-lib2to3 (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10-distutils.
Preparing to unpack .../python3.10-distutils_3.10.4-1+focal2_all.deb ...
Unpacking python3.10-distutils (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10-venv.
Preparing to unpack .../python3.10-venv_3.10.4-1+focal2_amd64.deb ...
Unpacking python3.10-venv (3.10.4-1+focal2) ...
Setting up python3.10-lib2to3 (3.10.4-1+focal2) ...
Setting up python3.10-distutils (3.10.4-1+focal2) ...
Setting up python3.10-venv (3.10.4-1+focal2) ...

파이썬 설치 확인

다음과 같이 파이썬(python) 3.10이 설치된 것을 확인할 수 있습니다.

$ python3.10 --version
Python 3.10.4

$ python3.10
Python 3.10.4 (main, Apr  8 2022, 17:35:13) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

참고자료