Skip to content

Instantly share code, notes, and snippets.

@William-Hill
Created October 18, 2017 18:56
Show Gist options
  • Save William-Hill/1919eb9858f9ea126bf68163c2888640 to your computer and use it in GitHub Desktop.
Save William-Hill/1919eb9858f9ea126bf68163c2888640 to your computer and use it in GitHub Desktop.
A shell script to install Python 2.7.13 with shared libraries and pip on CentOS
# 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.13:
wget http://python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
tar xf Python-2.7.13.tar.xz
cd Python-2.7.13
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
# Strip the Python 2.7 binary:
strip /usr/local/lib/libpython2.7.so.1.0
# First get the script:
wget https://bootstrap.pypa.io/get-pip.py
# Then execute it using Python 2.7 and/or Python 3.6:
python2.7 get-pip.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment