The Python team has released its latest version Python 3.8 for general use. You can download the latest stable version Python 3.8 series and install it on your system. This article will help you to install Python 3.8.12 on Ubuntu, Debian, and LinuxMint operating systems. You can visit here to read more about Python releases.

Advertisement

Step 1 – Installing Prerequisite

As you are going to install Python 3.8 from the source. You need to install some development libraries to compile Python source code. Use the following command to install prerequisites for Python:

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

Step 2 – Download Python 3.8

Download Python source code using the following command from python official site. You can also download the latest version in place of the specified below.

cd /opt
sudo wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz

Then extract the downloaded source archive file

sudo tar xzf Python-3.8.12.tgz

Step 3 – Compile Python Source

Use the below set of commands to compile Python source code on your system using the altinstall command.

cd Python-3.8.12
sudo ./configure --enable-optimizations
sudo make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Step 4 – Check Python Version

Check the installed version of python using the following command. As you have not overwritten the default Python version on the system, So you have to use Python 3.8 as follows:

python3.8 -V

Python-3.8.12

After successful installation remove the downloaded archive to save disk space

cd /opt
sudo rm -f Python-3.8.12.tgz

Conclusion

This tutorial helped you for installing Python 3.8 on Ubuntu, Debian, and Linux Mint systems by compiling it from source code.

Share.

56 Comments

  1. Instructions followed and everything seems to have worked.
    Noted that the install is in /opt –> is this how it’s supposed to be? Not /usr/bin?

  2. Mohee Jarada on

    Thanks a lot Rahul and really appreciate it: Excellent article. I followed your instructions under my Linux Mint Debian based and worked like hell…

    Happy Ramadan…
    Mohee from Doha

  3. You suggest installing checkinstall – then never use it. The following method, making use of checkinstall makes it far easier to update, or uninstall the Python version in the future.

    Also, you need the liblzma-dev dependency.

    Dependencies

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

    Download Tar and extract

    cd /opt
    sudo wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
    sudo tar xzf Python-3.8.6.tgz

    Compile and Install

    cd Python-3.9.1
    sudo ./configure –enable-optimizations
    make -n altinstall > altinstall_script.sh
    chmod +x altinstall_script.sh
    sudo checkinstall ./altinstall_script.sh

  4. Hi Rahul
    Thanks a lot. Before I wasted many hours of trying to install python3.8. On my Linuxcomputer there was python3.5.2 but programming with it doesn’t functioning fine.
    With this instructions it was no problem to get python3.8, I am happy.
    Many thanks and stay healthy.
    Michael

  5. Hello, and thank you for this important information. I have successfully installed Python 3.8 in Ubuntu three times now. Yet, every time I open my IDE (Spyder), Python 2.7 is running. When I write python in the Ubuntu terminal it shows python 2.7. When I write python 3.8 in the terminal, I get “python: can’t open file ‘3.8’ : [Errno 2] No such file or directory” Can you help? Thanks

  6. Great article from Rahul. Worked perfectly. Installed on Ubuntu 16.04 and WSL (1803 build 17134.1304).

    Allowed me to develop for Alpine 3.11.3 docker container which uses python 3.8.1

  7. Hallo Rahul,
    thank you for your great description.
    It worked proper on my raspberry pi and in a virtual machine with ubuntu18.04.

  8. Did not work for me. I copied, pasted and executed every command line RAHUL listed for the install, with no errors returned. Type in python3.8 -V as directed yields -bash: python3.8: command not found. Type in python3 -V and Python 3.5.3 is returned. Any other way to verify that the install was successful, or how to correct?

  9. Didn’t work for me. Looking in config.log, there’s

    configure:3870: $? = 0
    configure:3859: gcc -V >&5
    gcc: error: unrecognized command line option ‘-V’
    gcc: fatal error: no input files
    compilation terminated.

  10. I’ve installed and using it, but 3.8 doesn’t appear when I use “ls -ls /usr/bin/python*”, only the versions I had previously. Where it was installed?

  11. Laura,
    You might have just typed in Python3 instead of Python3.8. Just my guess.
    The reason it pulled up Python3.7.3 instead of Python3.8 is that you may have not told it you wanted Python3.8
    The default python binary file is usr/bin/python if you had followed Rahul’s instructions as posted above.

    This may not have answered your question fully but at least it will help point you in the right direction.

    P.s. sorry I did not realize I did not hit the Reply to Laura in my last comment.

  12. Laura,
    You might have just typed in Python3 instead of Python3.8. Just my guess.
    The reason it pulled up Python3.7.3 instead of Python3.8 is that you may have not told it you wanted Python3.8
    The default python binary file is usr/bin/python if you had followed Rahul’s instructions as posted above.

    This may not have answered your question fully but at least it will help point you in the right direction.

  13. Hi, thank you very much for this information.

    I have a question: where is the file with python3.8.0?

    in “ls -l / usr / bin / python *”

    Does not appear

  14. Carlos Rodriguez-Contreras on

    Thank you Rahul,
    now, I want you to suggest what next steps come first, I want to work with spyder:

    Must I create a virtual env for python 3.8 first and then install and declare such env inside spyder? or can I use the python default version of my system to install spyder and then declare only the path to python 3.8?

  15. Thanks a lot pal. Recently I switched Linux family – Ubuntu and was struggling to install Python 3.8. Your post helped.

  16. Thank you… Helped me a lot!
    just one more thing… for noobs like me 🙂

    do a

    $ cd ..

    before

    $ sudo rm -f Python-3.8.0.tgz

    because we’re still at the Python-3.8.0 folder

    then

    $ ls

    to see if folder still exist

    Thank a ton, Rahul

  17. Sorry, should have mentioned that the normal installers usually include sqlite. It’s included for e.g. REPL/ ipython history etc. I’ve compiled and installed Python a few times but still a bit fuzzy on installation.

Leave A Reply

Exit mobile version