Help us understand the problem. What is going on with this article?

EC2(Amazon Linux 2)にPython 3.8, Pip 3.8をインストールする

Amazon Linux2 に Python 3.8をインストール

Python 3.8, Pip 3.8をAmazon Linux2にインストールでお困りの方は参考にしてください。

  • EC2 AMI
     Amazon Linux 2 AMI (HVM)
     SSD Volume Type
     ami-062f7200baf2fa504 (64 ビット x86)/ami-0e98ccceff552e8a8 (64 ビット Arm)

事前準備

$ sudo yum -y update
$ sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel

ダウンロード

$ wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
$ tar xzf Python-3.8.1.tgz

インストール

$ cd Python-3.8.1
$ sudo ./configure --enable-optimizations
$ sudo make altinstall

確認

$ python3.8 --version
Python 3.8.1
$ pip3.8 --version
pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

rootのpathを設定

rootからもPython3.8を使えるようにパスを通しシンボリックリンクをはっておく

$ sudo which python3.8
which: no python3.8 in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo visudo
(Before)
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
(After)
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
$ sudo which python3.8
/usr/local/bin/python3.8
$ sudo ln -s /usr/local/bin/python3.8 /usr/local/bin/python3
$ sudo which python3
/usr/local/bin/python3
$ sudo ln -s /usr/local/bin/pip3.8 /usr/local/bin/pip3
$ sudo which pip3
/usr/local/bin/pip3
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした