• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Python 3.9 on Ubuntu 20.04

Written by Admin, Updated On December 20, 2020
python, ubuntu
How to Install Python 3.9 on Ubuntu 20.04

Python is most popular programming language. It is used by multiple ways to build different kinds of applications. Python 3.9 is the latest major release of the Python language. It includes many new features such as new dict operators, new str functions, support for IANA time zone, and more. This tutorial describes multiple ways to install Python 3.9 on Ubuntu 20.04 system.

Install Python 3.9 on Ubuntu with Apt#

It’s very simple and straightforward process to install Python 3.9 on Ubuntu using the apt packages manager.

Step 1 – Update packages list#

First, update the packages list and install required dependencies:

sudo apt update
sudo apt install software-properties-common

Step 2 – Enable Repository#

After that add the deadsnakes PPA to your system’s sources list by typing:

sudo add-apt-repository ppa:deadsnakes/ppa

Hit the Enter when you get prompt.

Step 3 – Install Python 3.9#

Once the repository enabled you can install the Python 3.9 by runnig below command:

sudo apt update
sudo apt install python3.9

Step 4 – Verify Installation#

To verify the installation, you would type:

python3.9 --version
Python 3.9.0+

At this stage, the Python 3.9 is installed on your Ubuntu 20.04 system.

Install Python 3.9 on Ubuntu from Source#

You can install the latest version of Python and customize the build options by compiling the Python from source. Below are the steps to install Python 3.9 from Python source:

Step 1 – Install dependencies#

You should install the required dependencies to build python. Run the following commands:

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Step 2 – Download source code#

After that download the latest source code from Python download page using wget:

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

Once the download is finished, extract the gzipped archive:

tar -xf Python-3.9.0.tgz

Step 3 – Configure script#

Navigate to the Python source directory and execute the configure script. It will do few checks that required dependencies are installed.

cd Python-3.9.0
./configure --enable-optimizations

The --enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

Step 4 – Start build process#

You would run the following command to start the build process for python:

make -j 12

For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.

Step 5 – Install Python#

Once the build process is complete, install the Python binaries by typing:

sudo make altinstall

That’s it. Python 3.9 has been installed from source and ready to be used. Verify the installation by typing:

python3.9 --version
Python 3.9.0+

Conclusion#

This tutorial shows you multiple ways to install Python 3.9 on Ubuntu 20.04 system. You can read here How to use Pip.

If you have any questions or feedback, leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to List Installed Repositories on Ubuntu & Debian
Next Article   How to Install GIMP 2.10 on Ubuntu 20.04

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook