• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Python 3.9 on Debian 9

Written by Rahul, Updated on December 20, 2020

Python is an object-oriented, high-level programming language. It is an open source with a large community. Python is used as key languages among the top tech companies like Google. 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.

The Debian 9 stretch comes with default Python 2.7 and 3.5. So you can install Python 3.5 directly from the default apt repositories using command apt install python3 . If you still need to install Python 3.9 on Debian 9, Go ahead with this tutorial.

This tutorial will describe you to how to install Python 3.9 on Debian 9 Stretch Linux system.

Prerequisites

Firstly, login to your Debian 9 system with sudo user. After login, update the current packages on your system to update packages.

sudo apt update && sudo apt upgrade 

After that, install belwo packages on your system, which is required for the installation of Python 3.9 from source code.

sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev \
     libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev  

Installing Python 3.9 on Debian

As you know, the default apt repositories contains Python 3.5 only. So to install latest packages, you need to compile it from source code. Use below steps to install Python 3.9 on Debian Stretch systems.

  1. Download Python – Download the Python 3.9 source code archive from its official website. alternatively use below wget command to download Python source code.
    wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz 
    
  2. Extract Archive – Next, extract the download archive file using the tar command. If required change your directory before extract.
    tar xzf Python-3.9.1.tgz 
    
  3. Compile Python Source – Switch to the extracted directory and configure the source code with enabling optimizations.
    cd Python-3.9.1 
    ./configure --enable-optimizations 
    
  4. Install Python 3.9 – Finally, run the make command to complete the Python installation. Here altinstall option is to install Python separately than default versions.
    make altinstall 
    

Wait for the Python installation complete on your system. All done.

Check Python Version

At this step, you have successfully installed Python 3.9 on Debian system. You need to type python3.9 to use this version. For example, to check the Python version, execute:

python3.9 -V 

Python 3.9.1

This will also install pip for Python 3.9.

pip3.9 -V 

pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

That’s it, You have successfully installed Python 3.9 on Debian 9 (Stretch) Linux system.

Conclusion

This tutorial described you to install Python 3.9 on Debian Linux systems using source code. You can try Python examples via command line.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar mcsebi Reply
    January 13, 2021 at 12:55 am

    I would also make python3.9 my default python installation, how do i do that?

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy