Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»Python»How To Install Python 3.9 on Ubuntu 20.04

    How To Install Python 3.9 on Ubuntu 20.04

    By RahulJuly 17, 20213 Mins Read

    Python is an object-oriented, high-level programming language. It is open-source with a large community. Python is used as a key language among the top tech companies like Google.

    Advertisement

    The Python 3.9 stable version has been released with several improvements and security updates. It included multiple new modules, improved existing modules, and many other features.

    You can choose deadsnakes PPA for Python installation on Ubuntu 20.04 system.

    Use this tutorial to install Python 3.9 On Ubuntu 20.04 LTS Linux system via Apt-Get. You can also choose the second method to install Python using source code.

    Prerequisites

    Login to your Ubuntu system and open a terminal, then install some required packages.

    sudo apt update 
    sudo apt install wget software-properties-common 
    

    Installing Python 3.9 Using Apt

    Use the Ubuntu package manager Apt to install Python 3.9 on Ubuntu Linux system. Follow the below steps:

    1. Open a terminal by pressing CTRL+ALT+T and then configure deadsnakes PPA to your system.
      sudo add-apt-repository ppa:deadsnakes/ppa 
      
    2. Once you added the PPA on your Ubuntu system, update the apt cache and install Python 3.9 on Ubuntu.
      sudo apt update 
      sudo apt install python3.9 
      
    3. Wait for the installation to complete. Check the Python version by executing:
      python3.9 -V 
      
      Python 3.9.6
      

    That’s it, You have successfully installed Python 3.9 on your Ubuntu 20.04 LTS system.

    Installing Python 3.9 Using Source Code

    You also have one more option to install Python 3.9 using source code. We don’t recommend installing Python 3.9 packages from source code. But in some cases, you may need to install Python from the source code.

    So follow the below instructions to install Python 3.9 using source code on Ubuntu 20.04 Linux system.

    1. First of all, install essential packages for compiling source code. Open a terminal and execute following commands:
      sudo apt install build-essential checkinstall 
      sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
          libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev 
      
    2. Now, download the Python 3.9 source code from the official download site. Switch to a relevant directory and use wget to download the source file.
      cd /opt 
      sudo wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz 
      
    3. Next, extract the downloaded archive file and prepare the source for the installation.
      tar xzf Python-3.9.6.tgz 
      cd Python-3.9.6 
      sudo ./configure --enable-optimizations 
      
    4. Python source is ready to install. Execute make altinstall command to install Python 3.9 on your system.
      sudo make altinstall 
      

      make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

    5. The Python 3.9 has been installed on Ubuntu 18.04 system. Verify the installed version:
      python3.9 -V 
      
      Python 3.9.6
      
    6. Remove the downloaded archive to free space
      sudo rm -f /opt/Python-3.9.6.tgz 
      

    Conclusion

    In this tutorial, you have learned to install Python 3.9 on Ubuntu 20.04 using Apt and source code. You can try Python examples via command line.

    Python Python3 Python3.9 Ubuntu 20.04
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Create and Read List in Python

    What are the Python Static Variables

    Python Program to Add Two Numbers

    View 6 Comments

    6 Comments

    1. Francis Cagney on September 14, 2021 4:40 pm

      To hell with Python3.9

      I also got: Python 3.10.0rc2 (default, Sep 9 2021, 23:13:40) [GCC 7.5.0] on linux
      just by sudo apt install python3.10

      Note 3.10.0 is a pre release. Only for those who enjoy pain.

      Reply
    2. MAZARIEGOS448 on January 1, 2021 4:34 pm

      Thank you!!1

      Reply
    3. Jaime on December 20, 2020 6:07 pm

      Thank you! This was quick and painless!

      Reply
    4. Hamza on December 3, 2020 3:34 pm

      Thank you! The method worked with me successfully and installed Python 3.9

      Reply
    5. Tim on November 17, 2020 8:12 am

      Thank you so much!!!!!!!!!!!!!!

      Reply
    6. Minas on November 1, 2020 2:39 pm

      Thank you very much!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.