-
-
Save andriisoldatenko/6d155ec6ca4fc9532bfc to your computer and use it in GitHub Desktop.
TMP_PATH=~/tmp_install_python | |
# Versions section | |
PYTHON_MAJOR=2.7 | |
PYTHON_VERSION=$PYTHON_MAJOR.10 | |
mkdir $TMP_PATH && cd $TMP_PATH | |
# Update yum and libraries | |
yum -y update | |
yum groupinstall -y development | |
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel | |
# Download and extract Python and Setuptools | |
wget --no-check-certificate https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz | |
wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | |
wget --no-check-certificate https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | |
tar -zxvf Python-$PYTHON_VERSION.tgz | |
# Compile Python | |
cd $TMP_PATH/Python-$PYTHON_VERSION | |
./configure --prefix=/usr/local | |
make && make altinstall | |
export PATH="/usr/local/bin:$PATH" | |
# Install Setuptools and PIP | |
cd $TMP_PATH | |
/usr/local/bin/python$PYTHON_MAJOR ez_setup.py | |
/usr/local/bin/python$PYTHON_MAJOR get-pip.py | |
# Finish installation | |
rm -rf $TMP_PATH | |
ln -s /usr/local/bin/python2.7 /usr/local/bin/python | |
ln -s /usr/local/bin/pip /usr/bin/pip | |
pip install virtualenv |
Thanks, just out of curiosity why isn't possible to update to this version directly using a simple yum command with the default CentOS repositories?
Also your fork of this script failed for me due to the URLs used in the wget commands. I noticed several forks of your fork updated the problem paths with:
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
Maybe you can update yours since it's the top google hit to save the next guy some time?
And on a final note, I needed to use the "force" flag to ln here: ln -sf /usr/local/bin/pip /usr/bin/pip
as I had existing symlink there for pip.
To anyone running this I suggest this execution to capture what happens and to abort on first failure:
bash -x -e install_python.sh 2>&1 | tee install_python.log
zlib-dev
should be zlib-devel
get-pip.py change to https://bootstrap.pypa.io/get-pip.py
Thanks for this, slightly modified version which worked for me
bash -x -e ./python2.7.sh 2>&1 | tee install_python.log
cat ./python2.7.sh
TMP_PATH=/tmp/tmp_install_python
Versions section
PYTHON_MAJOR=2.7
PYTHON_VERSION=$PYTHON_MAJOR.10
rm -rf $TMP_PATH
mkdir -p $TMP_PATH
cd $TMP_PATH
Update yum and libraries
yum -y update
yum groupinstall -y development
yum install -y zlib-devel openssl-devel sqlite-devel bzip2-devel
Download and extract Python and Setuptools
wget --no-check-certificate https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
tar -zxvf Python-$PYTHON_VERSION.tgz
Compile Python
cd $TMP_PATH/Python-$PYTHON_VERSION
./configure --prefix=/usr/local
make && make altinstall
export PATH="/usr/local/bin:$PATH"
Install Setuptools and PIP
cd $TMP_PATH
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
/usr/local/bin/python$PYTHON_MAJOR ez_setup.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
cd
rm -rf $TMP_PATH
# bash -x -e ./python2.7.sh 2>&1 | tee install_python.log
# cat ./python2.7.sh
TMP_PATH=/tmp/tmp_install_python
# Versions section
PYTHON_MAJOR=2.7
PYTHON_VERSION=$PYTHON_MAJOR.10
rm -rf $TMP_PATH
mkdir -p $TMP_PATH
cd $TMP_PATH
# Update yum and libraries
yum -y update
yum groupinstall -y development
yum install -y zlib-devel openssl-devel sqlite-devel bzip2-devel
# Download and extract Python and Setuptools
wget --no-check-certificate https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
tar -zxvf Python-$PYTHON_VERSION.tgz
# Compile Python
cd $TMP_PATH/Python-$PYTHON_VERSION
./configure --prefix=/usr/local
make && make altinstall
export PATH="/usr/local/bin:$PATH"
# Install Setuptools and PIP
cd $TMP_PATH
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
/usr/local/bin/python$PYTHON_MAJOR ez_setup.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
cd
rm -rf $TMP_PATH
Easy to copy @michalpirgl version.
It worked fine for me while the others failed 👍
reboot may be needed
python --version
nice work on this installation script.