python 2.6 to 2.7.14 on centos7

# Start by making sure your system is up-to-date:
yum update
# Compilers and related tools:
yum groupinstall -y “development tools”
# Libraries needed during compilation to enable all features of Python:
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
# If you are on a clean “minimal” install of CentOS you also need the wget tool:
yum install -y wget

# Python 2.7.14:
tar xf Python-2.7.14.tar.xz
cd Python-2.7.14
./configure –prefix=/usr/local –enable-unicode=ucs4 –enable-shared LDFLAGS=”-Wl,-rpath /usr/local/lib”
make && make altinstall

After running the commands above your newly installed Python interpreter will be available as /usr/local/bin/python2.7. The system version of Python 2.6.6 will continue to be available as /usr/bin/python, /usr/bin/python
You might also want to strip symbols from the shared library to reduce the memory footprint.

# Strip the Python 2.7 binary:
strip /usr/local/lib/libpython2.7.a

But you don’t need to change your default Python to get the system to run 2.7 when you type python.
First, you can set up a shell alias:
alias python=/usr/local/bin/python2.7

# Check the system Python interpreter version:
python –V

Install/upgrade pip, setuptools and wheel
# First get the script:

# Then execute it using Python 2.7 and/or Python 3.6:

Leave a Reply

Your email address will not be published. Required fields are marked *