Older systems still exist from time to time. Writing and managing python scripts for each version of python supported by these systems can be a daunting task.
When I looked it up, --Compile from source --Install from 2.6 rpm --Install using easy_install I found a method like this, but none of them had different procedures for each version, and it didn't look right.
I couldn't find a way to use pyenv, so I'll share it here.
By the way, you can also install centos6, RHEL6, centos7, RHEL7 by this procedure. In that case git will be installed with yum install git
Although it is possible with an actual machine, we will prepare vagrant as a verification environment that can be reproduced. This article has also been confirmed to work in this environment.
#Run on host
vagrant box add centos5 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-5.10-i386_chef-provisionerless.box
vagrant init
vagrant up
vagrant ssh
I will update it for the time being. Not required.
#Run with vm
sudo yum -y update
cat /etc/redhat-release
# CentOS release 5.11 (Final)
Since git is not included in Centos5 / RHEL5 by default, install it from EPEL.
#Run with vm
sudo rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo yum -y install --enablerepo=epel git
Install pyenv from github.
#Run with vm
git clone git://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 -l
Install the required packages with yum.
#Run with vm
sudo yum -y install gcc make
sudo yum -y install readline readline-devel
sudo yum -y install zlib zlib-devel
sudo yum -y install bzip2 bzip2-devel
sudo yum -y install sqlite sqlite-devel
sudo yum -y install openssl openssl-devel
When installing python3, install the following packages additionally.
#Run with vm
sudo yum -y install patch
List the versions that can be installed with pyenv.
#Run with vm
pyenv install -l
Among them, 2.7.12 is installed this time.
#Run with vm
pyenv install 2.7.12
pyenv global 2.7.12
#Run with vm
pip install requests
Recommended Posts