CentOSにpyenvをInstallしてPythonを2.6から2.7に切り替え

centos_pythonV8をビルドするときにpython 2.6だとエラーになったので2.7にアップデートしたときの覚書。

環境: CentOS 6.6

せっかくなのでnvmやrbenvみたいにバージョン管理システムpyenvをインストールしてみる。

 

参考

 

まずはクローン
# git clone https://github.com/yyuu/pyenv.git ~/.pyenv

パスの追加
# echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
# echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

初期化コマンドを追加
# echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

読み込み
# source ~/.bash_profile

コマンドの確認して、インストールできるバージョンを一覧表示
# pyenv help
# pyenv install -l

コマンドはGitHub上でも詳細を確認できる。

2.7.10をインストールする
# pyenv install 2.7.10

WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?

確認
# pyenv versions

* system (set by /root/.pyenv/version)
  2.7.10

2.7.10に切り替え
# pyenv global 2.7.10
# pyenv versions

  system
* 2.7.10 (set by /root/.pyenv/version)

# python -V

Python 2.7.10

 

WARNINGになってたreadline, bzip2, sqlite3をインストール
# yum install readline-devel bzip2-devel sqlite-devel

Pythonを再インストール
# pyenv install 2.7.10

 

 

< Related Posts >