Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save abelykh0/385248a0dbae8da667bd281863bc4e86 to your computer and use it in GitHub Desktop.

Select an option

Save abelykh0/385248a0dbae8da667bd281863bc4e86 to your computer and use it in GitHub Desktop.
Install Python 3.6 in Amazon Linux
# This script installs Python 3.6.9 on an Amazon Linux
# See original here: https://gist.github.com/niranjv/f80fc1f488afc49845e2ff3d5df7f83b
# The steps in this script are:
# - install pre-reqs
# - install Python 3.6
# - create virtualenv
# Install pre-requisites
sudo yum -y groupinstall development
sudo yum -y install zlib-devel
sudo yum -y install openssl-devel
# Install Python 3.6
PYTHON_VERSION=3.6.9
PYTHON_NAME=Python-${PYTHON_VERSION}
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_NAME}.tar.xz
tar xJf ${PYTHON_NAME}.tar.xz
cd ${PYTHON_NAME}
./configure --enable-shared # --enable-optimizations
# (this one takes a long time and uses 100% of CPU)
make install
# Clean up
cd ..
rm ${PYTHON_NAME}.tar.xz
sudo rm -rf ${PYTHON_NAME}
# This is needed because we require --enable-shared
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# Upgrade pip3
pip3 install --upgrade pip
# Create virtualenv running Python 3.6
pip3 install --upgrade virtualenv
virtualenv -p python3 python36
source python36/bin/activate
# Verify that it is working
python3 --version
# Should see "Python 3.6.9"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment