Wednesday, January 20, 2021

Install python2.7 alongside 2.6 on Centos6 or 7

# install python 2.7 alongside 2.6 on centos 6

* note this also works with python3 and 2.6.


# Install Dev tools
yum groupinstall -y "development tools"

# Install required libraries
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel

# Install wget if you don't already have it
yum install -y wget

# Download Python 2.7.14 package

# Unzip it
tar xvf Python-2.7.14.tar.xz

# Go into directory for install
cd Python-2.7.14 Python-2.7.14.tar.xz

# configure python2.7 in /usr/local/bin
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"

# Compile it as an alt-install (SUPER CRITICAL STEP!!!). This will allow you to run both existing python and newly installed python
sudo make && sudo make altinstall