Install Python on CentOS using pyenv

0. Environment

CentOS6.7

1. Install what you think you need

$ sudo yum groupinstall "Development tools"
$ sudo yum install gcc zlib-devel bzip2-devel openssl-devel readline-devel ncurses-devel sqlite-devel gdbm-devel db4-devel expat-devel libpcap-devel xz-devel pcre-devel

2. Install 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
$ exec $SHELL

2.1 Try to run it.

$ pyenv
pyenv 20151006-3-g1550129
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme

Ran.

2.2 Check the version that can be installed.

$ pyenv install --list
Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4
  2.4.1
  2.4.2
  2.4.3
  2.4.4
  2.4.5
  2.4.6
  2.5
  2.5.1
  2.5.2
  2.5.3
  2.5.4
  2.5.5
  2.5.6
  2.6.6
  2.6.7
  2.6.8
  2.6.9
  2.7-dev
  2.7
  2.7.1
  2.7.2
  2.7.3
  2.7.4
  2.7.5
  2.7.6
  2.7.7
  2.7.8
  2.7.9
  2.7.10
  3.0.1
  3.1
  3.1.1
  3.1.2
  3.1.3
  3.1.4
  3.1.5
  3.2-dev
  3.2
  3.2.1
  3.2.2
  3.2.3
  3.2.4
  3.2.5
  3.2.6
  3.3.0
  3.3-dev
  3.3.1
  3.3.2
  3.3.3
  3.3.4
  3.3.5
  3.3.6
  3.4.0
  3.4-dev
  3.4.1
  3.4.2
  3.4.3
  3.5.0
  3.5-dev
  3.6-dev
  anaconda-1.4.0
  anaconda-1.5.0
  anaconda-1.5.1
  anaconda-1.6.0
  anaconda-1.6.1
  anaconda-1.7.0
  anaconda-1.8.0
  anaconda-1.9.0
  anaconda-1.9.1
  anaconda-1.9.2
  anaconda-2.0.0
  anaconda-2.0.1
  anaconda-2.1.0
  anaconda-2.2.0
  anaconda-2.3.0
  anaconda3-2.0.0
  anaconda3-2.0.1
  anaconda3-2.1.0
  anaconda3-2.2.0
  anaconda3-2.3.0
  ironpython-dev
  ironpython-2.7.4
  ironpython-2.7.5
  jython-dev
  jython-2.5.0
  jython-2.5-dev
  jython-2.5.1
  jython-2.5.2
  jython-2.5.3
  jython-2.5.4-rc1
  jython-2.7.0
  jython-2.7.1b1
  jython-2.7.1b2
  miniconda-2.2.2
  miniconda-3.0.0
  miniconda-3.0.4
  miniconda-3.0.5
  miniconda-3.3.0
  miniconda-3.4.2
  miniconda-3.7.0
  miniconda-3.8.3
  miniconda-3.9.1
  miniconda-3.10.1
  miniconda-3.16.0
  miniconda3-2.2.2
  miniconda3-3.0.0
  miniconda3-3.0.4
  miniconda3-3.0.5
  miniconda3-3.3.0
  miniconda3-3.4.2
  miniconda3-3.7.0
  miniconda3-3.8.3
  miniconda3-3.9.1
  miniconda3-3.10.1
  miniconda3-3.16.0
  pypy-c-jit-latest
  pypy-c-nojit-latest
  pypy-dev
  pypy-stm-2.3
  pypy-portable-2.3.1
  pypy-portable-2.4
  pypy-portable-2.5
  pypy-portable-2.5.1
  pypy-stm-2.5.1
  pypy-portable-2.6.0
  pypy-portable-2.6.1
  pypy-1.5-src
  pypy-1.5
  pypy-1.6
  pypy-1.7-dev
  pypy-1.7
  pypy-1.8-dev
  pypy-1.8
  pypy-1.9-dev
  pypy-1.9
  pypy-2.0-dev
  pypy-2.0-src
  pypy-2.0
  pypy-2.0.1-src
  pypy-2.0.1
  pypy-2.0.2-src
  pypy-2.0.2
  pypy-2.1-src
  pypy-2.1
  pypy-2.2-src
  pypy-2.2
  pypy-2.2.1-src
  pypy-2.2.1
  pypy-2.3-src
  pypy-2.3
  pypy-2.3.1-src
  pypy-2.3.1
  pypy-2.4.0-src
  pypy-2.4.0
  pypy-2.4-beta1-src
  pypy-2.4-beta1
  pypy-2.5.0-src
  pypy-2.5.0
  pypy-2.5.1-src
  pypy-2.5.1
  pypy-2.6.0-src
  pypy-2.6.0
  pypy-2.6.1-src
  pypy-2.6.1
  pypy3-dev
  pypy3-portable-2.3.1
  pypy3-portable-2.4
  pypy3-2.3.1-src
  pypy3-2.3.1
  pypy3-2.4.0-src
  pypy3-2.4.0
  stackless-dev
  stackless-2.7-dev
  stackless-2.7.2
  stackless-2.7.3
  stackless-2.7.4
  stackless-2.7.5
  stackless-2.7.6
  stackless-2.7.7
  stackless-2.7.8
  stackless-3.2-dev
  stackless-3.2.2
  stackless-3.2.5
  stackless-3.3-dev
  stackless-3.3.5
  stackless-3.4.1

2.3 Install "2.7.10" and "3.5.0".

$ pyenv install 2.7.10
Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
Installed Python-2.7.10 to ~/.pyenv/versions/2.7.10

$ pyenv install 3.5.0
Downloading Python-3.5.0.tgz...
-> https://yyuu.github.io/pythons/584e3d5a02692ca52fce505e68ecd77248a6f2c99adf9db144a39087336b0fe0
Installing Python-3.5.0...
Installed Python-3.5.0 to ~/.pyenv/versions/3.5.0

$ pyenv rehash

2.4 Check the installed version.

$ pyenv versions
* system (set by ~/.pyenv/version)
  2.7.10
  3.5.0

$ pyenv global 2.7.10
$ python
Python 2.7.10 (default, Oct 28 2015, 11:37:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

2.5 Switch versions


$ pyenv global 3.5.0
$ python
Python 3.5.0 (default, Oct 28 2015, 11:40:43) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

Recommended Posts

Install Python on CentOS using Pyenv
Install Python on CentOS using pyenv
Install Python3.4 on CentOS 6.6
Install Python 2.7.3 on CentOS 5.4
[CentOS7] Install anaconda using pyenv
Install Python 3.8 on CentOS 7 (SCL)
Install Python 3.8 on CentOS 8 (AppStream)
Install Python 3.8.6 on macOS Big Sur using pyenv
Introducing Python using pyenv on Ubuntu 20.04
Notes on installing Python using PyEnv
CentOS8 --Install --Python3
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
Install python library on Lambda using [/ tmp]
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Install pyenv and rbenv on CentOS system-wide
Install python on WSL
Install Faiss on CentOS 7
Install Python on Pidora.
Install Python on Mac
Install Python 3 on Mac
Install python (pyenv, pyenv-virtualenv)
Install python on windows
Install mecab-python on CentOS
Install python with pyenv
Install Python 3.3 on Ubuntu 12.04
Install Python 3.4 on Mac
Install pyenv on OSX
Install awscli on centos7
Install Chainer on CentOS 6.7
Install Python 3.6 on Docker
[Ansible] Install dnf on Centos7 with Python3 interpreter
python (pyenv + pyenv-virtualenv) + CentOS7 installation
Install Python 3.8 on RHEL 8 (AppStream)
Install watchdog on Windows + Python 3.3
Install pygame on python3.4 on mac
Install ImageMagick-6.2.x series on CentOS7.7
Change python version using pyenv
Install pandas 0.14 on python3.4 [on Mac]
Install OpenCV on Ubuntu + python
Install Chrome on CentOS 7 series
Python --Install MySQLDB on EC2
Broadcast on LINE using python
[Python] [Chainer] [Windows] Install Chainer on Windows
Notes on installing Python on CentOS
Initial settings for using Python3.8 and pip on CentOS8
Build a Python environment on your Mac using pyenv
Build a Python development environment using pyenv on MacOS
Install Python environment on local PC (pyenv, venv on Mac)
Minimum memo when using Python on Mac (pyenv edition)
How to install python using anaconda
Install Python Pillow on Amazon Linux
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Steps to install MySQL 8.0 on CentOS 8.1
Install Python3 on Sakura server (FreeBSD)
raspberry pi 4 centos7 install on docker
install python
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Install python2.7 on windows 32bit environment
Notes on using MeCab from Python
Install xgboost (python version) on Windows
Preparing python using vscode on ubuntu