本文转载自 https://gist.github.com/niranjv/f80fc1f488afc49845e2ff3d5df7f83b
由于Amazon Linux中预装的Python版本为2.7,该脚本教程很好地解决了在Amazon Linux中安装Python3.6的需求,遂转发记录至此
# install pre-requisites sudo yum -y groupinstall development sudo yum -y install zlib-devel sudo yum -y install openssl-devel # Installing openssl-devel alone seems to result in SSL errors in pip (see https://medium.com/@moreless/pip-complains-there-is-no-ssl-support-in-python-edbdce548852) # Need to install OpenSSL also to avoid these errors sudo wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2l.tar.gz sudo tar -zxvf OpenSSL_1_0_2l.tar.gz cd openssl-OpenSSL_1_0_2l/
sudo ./config shared
sudo make
sudo make install
export LD_LIBRARY_PATH=/usr/local/ssl/lib/
cd .. sudo rm OpenSSL_1_0_2l.tar.gz sudo rm -rf openssl-OpenSSL_1_0_2l/ # Install Python 3.6 sudo wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz sudo tar xJf Python-3.6.0.tar.xz cd Python-3.6.0 sudo ./configure sudo make sudo make install cd .. sudo rm Python-3.6.0.tar.xz sudo rm -rf Python-3.6.0 # Create virtualenv running Python 3.6 sudo pip install --upgrade virtualenv virtualenv -p python3 MYVENV #到有权限的目录下 我是到家目录下 source MYVENV/bin/activate python --version # Python 3.6.0