Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Python 3.9 on Ubuntu 20.04 - DesignLinux

designlinux 0 Comments

Python is one of the world’s most popular programming languages. It is a versatile language used to build all kinds of applications, from simple scrips to complex machine learning algorithms. With its simple and easy to learn syntax, Python is a popular choice for beginners and experienced developers.

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 .

Python 3.8 is not available in the standard Ubuntu 20.04 repositories.

In this article, we’ll show you two ways to install Python 3.9 on Ubuntu 20.04. The first option is to install the package from the deadsnakes PPA, and the second one is to build Python 3.9 from the source code.

The same steps apply for Ubuntu 18.04 and all Ubuntu-based distribution, including Kubuntu, Linux Mint, and Elementary OS.

Installing Python 3.9 on Ubuntu with Apt #

Installing Python 3.9 on Ubuntu with apt is a relatively straightforward process and takes only a few minutes to complete.

  1. Update the packages list and install the prerequisites:

    sudo apt updatesudo apt install software-properties-common
  2. Add the deadsnakes PPA to your system’s sources list:

    sudo add-apt-repository ppa:deadsnakes/ppa

    When prompted, press [Enter] to continue.

  3. Once the repository is enabled, you can install Python 3.9 by executing:

    sudo apt install python3.9
  4. Verify that the installation was successful by typing:

    python3.9 --version
    Python 3.9.0+

That’s it. Python 3.9 is installed on your Ubuntu, and you can start using it.

Installing Python 3.9 on Ubuntu from Source #

Compiling Python from the source allows you to install the latest Python version and customize the build options. However, you won’t be able to maintain your Python installation through the apt package manager.

The following steps explain how to compile Python 3.9 from the source:

  1. Install the dependencies necessary to build Python:

    sudo apt updatesudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
  2. Download the latest release’s source code from the Python download page with wget :

    wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
  3. Once the download is complete, extract the gzipped archive :

    tar -xf Python-3.9.0.tgz
  4. Switch to the Python source directory and run the configure script, which performs a number of checks to make sure all of the dependencies on your system are present:

    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.

  5. Start the Python 3.9 build process:

    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.

  6. When the build process is complete, install the Python binaries by typing:

    sudo make altinstall

    We’re using altinstall instead of install because later will overwrite the default system python3 binary.

That’s it. Python 3.9 has been installed and ready to be used. To verify it, type:

python3.9 --version

The output should show the Python version:

Python 3.9.0+

Conclusion #

We’ve shown you how to install Python 3.9 on your 20.04 machine. You can now start developing your Python 3.9 project.

Next, you can read about How to Use Pip and How to Create Python Virtual Environments for different Python projects.

If you have any questions or feedback, feel free to comment below.

python ubuntu

Related

Tags: python, ubuntu

How to Read a File Line By Line in Bash

Prev Post

How to Install and Use i3 Window Manager on Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 67
  • 605,817

DesignLinux.com © All rights reserved

Go to mobile version