LoginSignup
45
51

More than 5 years have passed since last update.

Python3.6.0をUbuntu16.04に導入する。

Last updated at Posted at 2017-02-20

初期セットアップ。

sudo apt-get update
# gitが無い場合は
sudo apt-get install git 

# Pythonのビルドに必要なライブラリをインストールする。
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libbz2-dev libreadline-dev

pyenvをセットアップする。

pyenvはPythonのバージョン管理を行なうコマンドラインツールで、複数のバージョンのPythonのインストールや切り替えを容易に行うことができます。pyenvを利用すれば、既存のPythonの環境をいじることなく色んなバージョンのPythonを同居させることが可能です。

以下のコマンドを実行して下さい。

git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile
source ~/.profile

Python3.6.0をインストールする。

pyenv install 3.6.0

この状態ではまだデフォルトは2.x系なので、導入した3.6.0をglobalとして設定を反映させます。

pyenv global 3.6.0
# version確認
python -V
Python 3.6.0

以上です。
お疲れ様でした。

参考資料

45
51
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
45
51