How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)

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

Installation environment

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)

Install Git

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

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

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

install python

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

You can also use pip normally.

#Run with vm
pip install requests

Recommended Posts

How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
How to install python3 with docker centos
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
Unable to install Python with pyenv
Install Python on CentOS using Pyenv
How to install Maven on CentOS
Install Python on CentOS using pyenv
How to install Anaconda with pyenv
[Kivy] How to install Kivy on Windows [Python]
How to install Apache (httpd) on CentOS7
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
How to install Python
How to install python
Install Python3.4 on CentOS 6.6
How to use python put in pyenv on macOS with PyCall
Install Python 2.7.3 on CentOS 5.4
Install python with pyenv
[2020 version] How to install Python3 on AWS EC2
Strategy on how to monetize with Python Java
How to install OpenCV on Jetson Nano Python
[Ansible] Install dnf on Centos7 with Python3 interpreter
I wanted to install Python 3.4.3 with Homebrew + pyenv
How to install OpenGM on OSX with macports
How to use tkinter with python in pyenv
[Python] How to install OpenCV on Anaconda [Windows]
How to install Python [Windows]
Install Python 3.8 on RHEL 8 (AppStream)
Install Python 3.8 on CentOS 7 (SCL)
Install Python 3.8 on CentOS 8 (AppStream)
How to install Git GUI and Gitk on CentOS
How to install caffe on OS X with macports
How to install python using anaconda
Steps to install MySQL 8.0 on CentOS 8.1
How to install NPI + send a message to line with python
How to install mysql-connector-python on mac
[Ev3dev] How to display bmp image on LCD with python
How to install python-pip with ubuntu20.04LTS
Steps to install VirtualBox on CentOS
How to install graph-tool on macOS
How to install VMware-Tools on Linux
How to install pycrypto on Windows
How to install OpenCV on Mac
Install pyenv on MacBook Air and switch python to use
How to get started with Python
How to use FTP with Python
How to calculate date with python
How to install mysql-connector with pip3
Steps to install python3 on mac
How to install Theano on Mac OS X with homebrew
Install python2.x on catalina with pyenv
How to install Go on Ubuntu
How to install music 21 on windows
How to deal with python installation error in pyenv (BUILD FAILED)
How to install OpenCV on Cloud9 and run it in Python
How to rebuild python environment from pyenv on Mac environment (El Capitan)
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Install Python as a Framework with pyenv