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 Debian 9

    How to Install Python 3.9 on Debian 9

    By RahulDecember 10, 20203 Mins ReadUpdated:April 7, 2021

    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.

    Advertisement

    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.4/Python-3.9.4.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.4.tgz 
      
    3. Compile Python Source – Switch to the extracted directory and configure the source code with enabling optimizations.
      cd Python-3.9.4 
      ./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.4
    

    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.

    debian Debian 9 Python Python3 Python3.9
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Install Python 3.11 on Amazon Linux 2

    Installing Python 3.11 on Debian Linux

    How To Install Python 3.11 on Debian 11/10

    Installing Python 3.11 on Ubuntu, Debian and LinuxMint

    How To Install Python 3.11 on Ubuntu, Debian and LinuxMint

    View 5 Comments

    5 Comments

    1. scott on August 27, 2022 5:47 am

      This doesn’t work.. When I download the python version on my version 3 pi and try to import a package (numpy) I receive this error:

      Traceback (most recent call last):
      File “/home/pi/.local/lib/python3.9/site-packages/numpy/core/__init__.py”, line 23, in
      from . import multiarray
      File “/home/pi/.local/lib/python3.9/site-packages/numpy/core/multiarray.py”, line 10, in
      from . import overrides
      File “/home/pi/.local/lib/python3.9/site-packages/numpy/core/overrides.py”, line 6, in
      from numpy.core._multiarray_umath import (
      ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File “”, line 1, in
      File “/home/pi/.local/lib/python3.9/site-packages/numpy/__init__.py”, line 140, in
      from . import core
      File “/home/pi/.local/lib/python3.9/site-packages/numpy/core/__init__.py”, line 49, in
      raise ImportError(msg)
      ImportError:

      IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

      Importing the numpy C-extensions failed. This error can happen for
      many reasons, often due to issues with your setup or how NumPy was
      installed.

      We have compiled some common reasons and troubleshooting tips at:

      https://numpy.org/devdocs/user/troubleshooting-importerror.html

      Please note and check the following:

      * The Python version is: Python3.9 from “/usr/local/bin/python3.9”
      * The NumPy version is: “1.23.2”

      and make sure that they are the versions you expect.
      Please carefully study the documentation linked above for further help.

      Original error was: libcblas.so.3: cannot open shared object file: No such file or directory

      Reply
    2. Mauricio Gomez on June 11, 2021 2:27 am

      It did work, with “sudo make altinstall”. Where is the executable located? I want to run script, but I don’t know where to point the shebang.

      Reply
    3. ALeksandr on April 1, 2021 1:10 pm

      sudo make altinstall

      Reply
    4. mcsebi on January 13, 2021 12:55 am

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

      Reply
      • Abhishek on June 13, 2021 6:22 pm

        1. Enter bash shell script
        sudo nano ~/.bashrc
        2. Enter aliases for python 3.9
        alias python=python3.9
        alias pip=pip3.9
        3. Save the changes to the script and exit
        Ctrl+S followed by Ctrl+X

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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