Search code examples
pythonlinuxamazon-web-servicesamazon-ec2aws-cloud9

How to install/configure python 3.7 on Amazon1 EC2 instance (Cloud9)?


I am using AWS Cloud9 Amazon1 (EC2) instance.

Python 2.7 is pre-installed.

I am not sure where the python 3.7 is to be installed - home dir or root dir? Can someone help me with the steps to install python 3.7 such that it meets the following criteria:

If Python 3.7 is installed on the device, name the binary 'python3.7' and add its parent directory to the PATH environment variable.

Note that apt-get is not supported. yum works.

Update:

I have followed the steps from answer and installed python 3.7 successfully and checked by firing python3.7 -V. However, the dependency checker is unable to detect the python 3.7:

mkdir greengrass-dependency-checker-GGCv1.11.x
cd greengrass-dependency-checker-GGCv1.11.x
wget https://github.com/aws-samples/aws-greengrass-samples/raw/master/greengrass-dependency-checker-GGCv1.11.x.zip
unzip greengrass-dependency-checker-GGCv1.11.x.zip
cd greengrass-dependency-checker-GGCv1.11.x
sudo ./check_ggc_dependencies | more

Solution

  • Based on the comments.

    There is no native package for python 3.7 on Amazon Linux 1. Thus, it should be compiled as shown here. The compilation steps include:

    1. Installation of dependencies,
    yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
    
    1. Downloading python source:
    cd /usr/src
    wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
    
    1. Extract Python-3.7.9
    tar xzf Python-3.7.9.tgz
    
    1. Compilation
    cd Python-3.7.9
    ./configure --enable-optimizations
    make altinstall
    
    1. Cleanup
    rm /usr/src/Python-3.7.9.tgz
    

    Update

    Need to sym link pyhton:

    ln -s /usr/local/bin/python3.7 /usr/bin/python3.7
    

    enter image description here