우분투18.04에 Python3.7 설치하는 방법입니다. 아직 apt에서 제공하지 않아 직접 다운받아 설치하였습니다. 또한 Alternatives를 사용하여 버전을 쉽게 변경할 수 있게 하였습니다.
python3.7 직접 설치
먼저 기본적인 프로그램들을 설치해야 합니다.
$ sudo apt-get install -y build-essential
$ sudo apt-get install -y checkinstall
$ sudo apt-get install -y libreadline-gplv2-dev
$ sudo apt-get install -y libncursesw5-dev
$ sudo apt-get install -y libssl-dev
$ sudo apt-get install -y libsqlite3-dev
$ sudo apt-get install -y tk-dev
$ sudo apt-get install -y libgdbm-dev
$ sudo apt-get install -y libc6-dev
$ sudo apt-get install -y libbz2-dev
$ sudo apt-get install -y zlib1g-dev
$ sudo apt-get install -y openssl
$ sudo apt-get install -y libffi-dev
$ sudo apt-get install -y python3-dev
$ sudo apt-get install -y python3-setuptools
$ sudo apt-get install -y wget
그리고 weget으로 python3.7 소스를 받고 설치합니다.
$ wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
$ tar xvf Python-3.7.0.tar.xz
$ cd Python-3.7.0
$ ./configure
$ sudo make altinstall
python3.7
이 설치되었는지 확인합니다.
$ python3.7 --version
Python 3.7.0
Alternatives으로 python 설정
alternatives을 사용하면 python의 버전 변경을 쉽게 할 수 있습니다.
예를 들어, python3.7을 사용하고 있다가 python2.7로 변경을 하고 싶을 때 alternatives라는 툴이 이것을 쉽게 하도록 도와줍니다.
먼저 alternatives에 python을 등록하기 위해 python3.7이 실제 어떤 path에 설치되었는지 확인합니다.
$ which python3.7
/usr/local/bin/python3.7
아래와 같은 명령어로 alternative를 등록해주고, python3.7
을 기본 python으로 설정하였습니다. install 명령어의 마지막 숫자는 개인마다 다를 수 있습니다.
alternative 설정 방법은 여기를 참고해주세요.
$ sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 3
update-alternatives: using /usr/local/bin/python3.7 to provide /usr/bin/python (python) in auto mode
$ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.7 3 auto mode
1 /usr/bin/python2.7 1 manual mode
2 /usr/bin/python3.6 2 manual mode
3 /usr/local/bin/python3.7 3 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
이제 python이 3.7로 변경되었습니다.
$ python --version
Python 3.7.0
참고
Recommended Posts:
- Ubuntu 20.04 - SSH 설치와 접속 방법
- Ubuntu에서 imwheel로 마우스 휠 스크롤 속도 변경
- Ubuntu에서 사용할 수 있는 Text Editor 소개
- Ubuntu 20.04 - OpenJDK 11 설치, 삭제
- Ubuntu 20.04 - VLC Player 설치
- Linux의 apt-get 명령어
- apt remove, purge, autoremove 명령어 차이점
- Ubuntu 20.04 - 토렌트 설치
- Ubuntu에서 사용할 수 있는 그림판(mspaint)과 비슷한 툴 소개
- Linux - Hardware 정보를 보여주는 명령어
- Ubuntu에 OpenJdk 9 설치하는 방법
- AutoKey 설치 및 macro 만들기
- Linux - Bash 쉘스크립트 파일의 절대경로 얻기