Last active
October 25, 2018 10:12
-
-
Save AvnerCohen/3e5cbe09bc40231869578ce7cbcbe9cc to your computer and use it in GitHub Desktop.
Updated Python 2.7.xx on an Amazon AMI + make it default (in alternatives) and symlik pip ad virtualenv for future usage
This file contains 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
#!/usr/bin/env bash | |
NEW_VERSION="2.7.14" | |
CURRENT_VERSION="$(python -V 2>&1)" | |
if [[ "$CURRENT_VERSION" == "Python $NEW_VERSION" ]]; then | |
echo "Python $NEW_VERSION already installed, aborting." | |
else | |
echo "Starting upgrade from ${CURRENT_VERSION} to ${NEW_VERSION}" | |
if [ ! -d "python_update" ]; then | |
mkdir python_update | |
cd python_update | |
wget https://www.python.org/ftp/python/$NEW_VERSION/Python-$NEW_VERSION.tgz | |
tar xfz Python-$NEW_VERSION.tgz | |
cd Python-$NEW_VERSION/ | |
else | |
cd python_update | |
cd Python-$NEW_VERSION/ | |
fi | |
./configure --enable-loadable-sqlite-extensions --prefix /usr/local/lib/python$NEW_VERSION --enable-ipv6 --enable-unicode=ucs4 --enable-shared | |
make && make install | |
alternatives --install /usr/bin/python python /usr/local/lib/python$NEW_VERSION/bin/python2.7 $(echo $NEW_VERSION | sed 's/\.//g')0 | |
update-alternatives --refresh python | |
update-alternatives --auto python | |
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python | |
ln -sf /usr/local/lib/python$NEW_VERSION/bin/pip /usr/bin/pip | |
pip install -U virtualenv | |
ln -sf /usr/local/lib/python$NEW_VERSION/bin/virtualenv /usr/bin/virtualenv | |
echo "DONE!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Like the retry for get-pip 👍