Python 3.10 installation on Amazon Linux 2

Python 3.10.2 is the newest major release of the Python programming language, which was released on Jan. 14, 2022. This post explains how to install Python 3.10 on Amazon Linux 2.

Python 3.10 Installation Steps :

①: Install the necessary build dependencies.
   

sudo yum -y groupinstall "Development Tools"

sudo yum -y install gcc devel libffi-devel openssl11 openssl11-devel


②: Download the Python Gzipped source file.
       

wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz


③: Unpack the .tgz file.
      

tar zxvf Python-3.10.2.tgz

  
  

④: Navigate to Python-3.10.2 folder.
      

cd Python-3.10.2/

  
  

⑤: Execute configure script.
      

./configure

  
  

⑥: Build the Python 3.10 binary.
  

make


If you are getting errors like Could not build the ssl module! Python requires a OpenSSL 1.1.1 or newer, verify that you are installing openssl11 and openssl11-devel in Step 1.

⑦: Install the Python 3.10 binary.
      

sudo make altinstall

  
  

⑧ : Verify Python 3.10 installation.
  

python3.10 --version

# Output
Python 3.10.2


⑨ : Navigate to home directory.
  
cd ~    

⑩ : Create new virtual environment.

python3.10 -m venv myvenv 
  
  
  

⑪ : Activate new virtual environment.
   
source myvenv/bin/activate  

    
    

⑫ : Install requests module.
      
pip install requests    

      
      

⑫ : Deactivate virtual environment.
     
deactivate   
      
      


Category: Python