Ubuntu에 Python 3.7 Install 하기

최근 Ubuntu는 Python을 3.8을 기본으로 해서 릴리즈 되고 있다.

그런데 문제는 Panda 나 Numpy등의 Dependencies가 3.7에 맞추어져 있어서

프로젝트 빌드가 안되는 경우가 많았다.

 

그래서 Python 3.7을 추가로 설치해 보겠다. 

- 원래는 3.8을 삭제하고 3.7을 default로 설치 하려고 했었는데.. 리눅스 몇번 날려먹고... 3.8쓸때는 이유가 있겠지..

인스톨 하는데 필요한 패키지를 설치해 준다.

- sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev wget libbz2-dev

이걸 다 install 해줘야 할 꺼 같다.

ubuntu@master:~$ sudo apt-get install libffi-dev gcc zlib1g-dev
[sudo] password for ubuntu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libffi-dev
0 upgraded, 1 newly installed, 0 to remove and 57 not upgraded.
Need to get 57.5 kB of archives.
After this operation, 314 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu groovy/main amd64 libffi-dev amd64 3.4~20200819gead65ca871-0ubuntu3 [57.5 kB]
Fetched 57.5 kB in 1s (49.3 kB/s)                      
Selecting previously unselected package libffi-dev:amd64.
(Reading database ... 77173 files and directories currently installed.)
Preparing to unpack .../libffi-dev_3.4~20200819gead65ca871-0ubuntu3_amd64.deb ...
Unpacking libffi-dev:amd64 (3.4~20200819gead65ca871-0ubuntu3) ...
Setting up libffi-dev:amd64 (3.4~20200819gead65ca871-0ubuntu3) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
Processing triggers for man-db (2.9.3-2) ...

 

Python Download & install

 

configure setting

wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
tar -xf Python-3.7.4.tgz
./configure --enable-optimizations
sudo make
sudo make altinstall

 

change Directory to python3.7 then,

- make altinstall

running install_scripts
copying build/scripts-3.7/idle3.7 -> /usr/local/bin
copying build/scripts-3.7/pydoc3.7 -> /usr/local/bin
copying build/scripts-3.7/pyvenv-3.7 -> /usr/local/bin
copying build/scripts-3.7/2to3-3.7 -> /usr/local/bin
changing mode of /usr/local/bin/idle3.7 to 755
changing mode of /usr/local/bin/pydoc3.7 to 755
changing mode of /usr/local/bin/pyvenv-3.7 to 755
changing mode of /usr/local/bin/2to3-3.7 to 755
rm /usr/local/lib/python3.7/lib-dynload/_sysconfigdata_m_linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.7/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.7.1
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmp4i7bemke
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0
ubuntu@master:~/Python-3.7.3$ 
ubuntu@master:~/Python-3.7.3$ cd /usr/local/bin
ubuntu@master:/usr/local/bin$ ls
2to3-3.7  easy_install-3.7  idle3.7  pip3.7  pydoc3.7  python3.7  python3.7m  python3.7m-config  pyvenv-3.7
ubuntu@master:/usr/local/bin$ 

 

티스토리 문제인지 내문제인지 모르겠지만 Code 블럭 하단에 한글이 써지지 않는다.

상기 코드를 보면 알겠지만 3.7이 인스톨 되고 /usr/local/bin 하단으로 관련 command가 설치 된다.

python3.7 -m venv ~/.devops

라고 하는 Virtual 환경을 잡아 주고

source ~/.devops/bin/activate

하면 (.devops)라는 환경이 표시되는한은 python은 3.7이 된다.

(.devops) ubuntu@master:~/project-ml-microservice-kubernetes$ python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/fe/ef/60d7ba03b5c442309ef42e7d69959f73aacccd0d86008362a681c4698e83/pip-21.0.1-py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 32.3MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-21.0.1
(.devops) ubuntu@master:~/project-ml-microservice-kubernetes$ 

 

728x90
반응형

'Software활용' 카테고리의 다른 글

kubernetes guestbook CICD (Blue/Green 배포)  (0) 2021.04.04
kubeadm join 실패  (2) 2021.03.08
kubernetes reset 하기  (0) 2021.03.07
kubernetes install on ubuntus with Hyper-V  (0) 2021.03.04
Kubernetes Deployments No resources  (0) 2021.03.01