Skip to content

Instantly share code, notes, and snippets.

@voodoonofx
Last active December 19, 2015 01:14
Show Gist options
  • Save voodoonofx/08310edc36ad78f2f08a to your computer and use it in GitHub Desktop.
Save voodoonofx/08310edc36ad78f2f08a to your computer and use it in GitHub Desktop.
Install Python 2.x and 3.x
#!/bin/bash
### Python
# Setup python from source, for multiple versions of it. This only works with whole version numbers, not alpha releases.
# CentOS requires these packages:
# sudo yum -y install gcc automake autoconf
# sudo yum -y install readline-devel ncurses-devel openssl-devel sqlite-devel tk-devel gdbm-devel bzip2-devel
# Ubuntu requires:
# sudo apt-get install libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
# Some people will prefer this to be /usr/local or /var/local, or whatever.
PREFIX=/opt
cd /tmp
for VERSION in 2.7.9 2.7.10 3.4.3
do
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz
tar zxvf Python-$VERSION.tgz
cd Python-$VERSION
./configure --with-signal-module --with-threads --prefix=${PREFIX}/python-$VERSION
make -j 8 && \
sudo make install && \
if [ ${VERSION:0:1} = "2" ]; then
curl https://bootstrap.pypa.io/get-pip.py | sudo ${PREFIX}/python-$VERSION/bin/python
# (Optional)
sudo ${PREFIX}/python-$VERSION/bin/pip install supervisor
fi
sudo ${PREFIX}/python-$VERSION/bin/pip${VERSION:0:1} install virtualenv
done
# Verify it installed correctly by listing out pip for each version
ls -l ${PREFIX}/python-*/bin/{pip,virtualenv}*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment