LoginSignup
4
13

More than 3 years have passed since last update.

Python 3.6 を Ubuntu 16.04LTSにソースからインストール

Last updated at Posted at 2018-02-11

概要

Ubuntu16.04LTSではPython3.6のパッケージが公式には提供されていません。
ここでは、Python3.6.7をダウンロードして、ソースからインストールする方法を記します。

依存関係があるパッケージのインストール

terminal
sudo apt update && sudo apt upgrade
sudo apt install build-essential \
                 libreadline-gplv2-dev \
                 libncursesw5-dev \
                 libssl-dev \
                 libsqlite3-dev \
                 tk-dev \
                 libgdbm-dev \
                 libc6-dev \
                 libbz2-dev 

ダウンロードと解凍

terminal
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar -xvf Python-3.6.9.tgz
cd Python-3.6.9/

configure, make and install

普通にsudo make installするとシステムのpython3のリンクを破壊する可能性があるため、make install の代わりに /usr/local/bin/pythonversion のみをインストールするmake altinstallが推奨されています。

terminal
# システムワイドにインストールする場合
./configure --enable-shared --enable-optimizations
sudo make altinstall

# homeディレクトリ下にインストールする場合
./configure --prefix=$HOME/usr --enable-shared --enable-optimizations
make altinstall

インストールされているか確認

python3.6 -Vとターミナルで入力し、Python 3.6.9と返ってくれば成功です。

参考

https://qiita.com/yniji/items/8e392103a6f2a4152606
http://www.techtrekking.net/install-python-3-6-4-on-ubuntu-16-04/
https://docs.python.jp/3/using/unix.html

4
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
13