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. After that, install belwo packages on your system, which is required for the installation of Python 3.9 from source code.

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. 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: This will also install pip for 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.