-
-
Save towens/2f8bc99e7bc2956882357e38f108ba86 to your computer and use it in GitHub Desktop.
Install local Python 2.7.10 on CentOS 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TMP_PATH=~/tmp_install_python | |
# Versions section | |
PYTHON_MAJOR=2.7 | |
PYTHON_VERSION=$PYTHON_MAJOR.14 | |
rm -rf $TMP_PATH | |
mkdir $TMP_PATH | |
cd $TMP_PATH | |
# openssl dance | |
# wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.0g.tar.gz | |
# tar -zxvf openssl-1.1.0g.tar.gz | |
# cd openssl-1.1.0g | |
# ./config | |
# make && make install | |
#cd $TMP_PATH | |
# Update yum and libraries | |
yum -y update | |
yum groupinstall -y development | |
yum install -y ncurses-devel readline-devel tk-devel zlib zlib-dev openssl-devel \ | |
sqlite-devel bzip2-devel openssh openssl openssl-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel wget | |
# Download and extract Python and Setuptools | |
wget --no-check-certificate https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz | |
tar -zxvf Python-$PYTHON_VERSION.tgz | |
# Compile Python | |
cd $TMP_PATH/Python-$PYTHON_VERSION | |
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
make && make altinstall | |
export PATH="/usr/local/bin:$PATH" | |
# Install Setuptools and PIP | |
cd $TMP_PATH | |
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py | |
/usr/local/bin/python$PYTHON_MAJOR get-pip.py | |
# Finish installation | |
rm /usr/local/bin/python | |
ln -s /usr/local/bin/python2.7 /usr/local/bin/python | |
rm /usr/bin/pip | |
ln -s /usr/local/bin/pip /usr/bin/pip | |
pip install virtualenv | |
pip install setuptools | |
cd | |
rm -rf $TMP_PATH | |
# reload shell after adding $USER to docker group | |
exec $SHELL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment