sh 在Amazon Linux中安装Python 3.6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Amazon Linux中安装Python 3.6相关的知识,希望对你有一定的参考价值。

# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda
# and can be used for developing/testing Python 3.6 Lambda functions
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python
# This is required because Amazon Linux does not come with Python 3.6 pre-installed 
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime

# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm)
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3
# and was developed with the help of AWS Support

# 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


# 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
wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2l.tar.gz
tar -zxvf OpenSSL_1_0_2l.tar.gz 
cd openssl-OpenSSL_1_0_2l/

./config shared
make
sudo make install
export LD_LIBRARY_PATH=/usr/local/ssl/lib/

cd ..
rm OpenSSL_1_0_2l.tar.gz
rm -rf openssl-OpenSSL_1_0_2l/


# Install Python 3.6
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xJf Python-3.6.0.tar.xz
cd Python-3.6.0

./configure
make
sudo make install

cd ..
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

以上是关于sh 在Amazon Linux中安装Python 3.6的主要内容,如果未能解决你的问题,请参考以下文章

在 Amazon Linux 中安装 Jenkins 时出错

text 如何使用PHP7在Amazon Linux中安装Xdebug

在 linux(Amazon ami) 中安装 php-fpm 没有可用的软件包错误

在 Google Colaboratory 中安装 Python 3.8 内核

sh 在bash中安装python库

如何在ubuntu中安装pycharm