Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Install Python 3.7 on Ubuntu, Debian and LinuxMint

    How to Install Python 3.7 on Ubuntu, Debian and LinuxMint

    By RahulAugust 21, 20202 Mins Read

    At the writing time of this article Python 3.7.9 latest stable version of 3.7 series is available to install. This article will help you to install Python 3.7.9 on Ubuntu and LinuxMint operating system. You can visit here to read more about Python releases.

    Advertisement

    Prerequisites

    It is an good practice to keep packages up to date. So, first of all upgrade current packages on your system by running following commands.

    sudo apt update && sudo apt upgrade
    

    Then, Use the following command to install prerequisites for Python before installing it.

    sudo apt-get install wget 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 1 – Download Python 3.7

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

    cd /usr/src
    sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
    

    After finishing the downloading, extract the archive file.

    sudo tar xzf Python-3.7.9.tgz
    

    Step 2 – Install Python 3.7

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

    cd Python-3.7.9
    sudo ./configure --enable-optimizations
    sudo make altinstall
    

    make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

    Step 3 – Check Python Version

    Check the latest version installed of python using below command

    python3.7 -V
    
    Python-3.7.9
    

    Conclusion

    This tutorial helps you to install Python 3.7 on your Ubuntu, Debian and Linuxmint systems.

    Python Python3 Python3.7
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Python Function with Parameters, Return and Data Types

    What are the difference between SH and BASH

    What are the difference between SH and BASH?

    Understanding Python’s Underscore ( _ ): A Comprehensive Guide

    View 129 Comments

    129 Comments

    1. Maurice on November 25, 2021 3:22 pm

      Thank you very much, it works perfectly !

      Reply
    2. John on November 13, 2021 12:11 pm

      Great instructions, thank you.

      Trying to run ‘pipenv run python setup.py install’ on Mint 20 is successful up to the end, then;
      self.set_undefined_options(‘install’,(‘install_layout’,’install_layout’))
      File “/usr/local/lib/python3.7/distutils/cmd.py”, line 290, in set_undefined_options
      setattr(self, dst_option, getattr(src_cmd_obj, src_option))
      File “/usr/local/lib/python3.7/distutils/cmd.py”, line 103, in __getattr__
      raise AttributeError(attr)
      AttributeError: install_layout

      Can anyone suggest a solution?

      Reply
    3. Edwin on April 2, 2021 9:04 pm

      this worked for me but have an issue where only the user that installed python can utilize it. When I become root or another user the command python3.7 doesn’t bring up python. any guide how to make this work for all users on this machine.

      Here is the response when I call which python3.7:
      which python3.7
      /usr/local/bin/python3.7

      becoming another user:
      which python3.7
      /usr/bin/which: no python3.7 in (/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/home/cod/.local/bin:/home/cod/bin)

      Reply
    4. davidm on January 2, 2021 6:11 pm

      I have a 16.04 version of Ubuntu which comes with python 3.5. I am not a python guy at all but I need python 3.7 to run an application. I would like to replace 3.5 with 3.7 in /usr/bin. The instructions on this page for downloading and creating python 3.7 seemed to work perfectly (thanks so much for that). However, I need 3.7 to be my default python3 version. I tried using ‘make install’ instead of ‘make altinstall’ to no effect. How do I do this?
      Regards.

      Reply
      • Naveen Vasudevan on February 27, 2021 1:47 am

        sudo update-alternatives –config python3 run this command and then select your required version from the list

        Reply
    5. tyson on December 8, 2020 6:20 am

      great easy to follow instructions

      Reply
    6. PosReady on November 23, 2020 6:56 pm

      Hey, i installed Python 3.7.8 on Manjaro (Arch) and instruction for installing/compiling Python 3.7.x:

      please install gcc before download python.

      (sudo pacman -S gcc)

      okay. Next install make:
      (sudo pacman -S make)

      and going to download the python on instruction and compiling.

      Good Luck

      Reply
    7. Espresso Man on November 6, 2020 1:33 pm

      Thanks for posting that info and updating it Rahul. Well done.

      Reply
    8. Gunter on August 5, 2020 7:25 am

      Hi Rahul,

      very useful tutorial, I used it to install Python 3.7 on my ARM64 Odroid C4 running Ubuntu 20.04 – and it worked!

      Thanks mate!

      Reply
    9. Jan on July 6, 2020 4:11 pm

      Hi Rahul,

      this is very helpful! thanks a lot.

      One small input: on my system, I didnt have wget installed. Maybe adding the command sudo apt install wget would make this post even better.

      Cheers,
      Jan

      Reply
      • Rahul on July 8, 2020 7:08 am

        Thanks Jan, Added command to install wget.

        Reply
    10. Peter on July 4, 2020 6:31 pm

      A big “Thank you!” Rahul for your very clean and complete description that has reliably installed Python 3.7 on my Ubuntu 18.10.

      Reply
    11. Danilo Dara on May 28, 2020 5:30 pm

      3.7.7 onboard and running.
      Thank you so much.

      Reply
    12. ADG on May 7, 2020 11:26 pm

      so helpfull

      Reply
    13. Sunnchilde on November 12, 2019 8:23 pm

      Thank you so much! That worked great.

      Reply
    14. No on October 28, 2019 1:52 pm

      Installing works fine, but what if I want to unistall it (altinstall)? make unistall does not work 🙁

      Reply
    15. Maria Carmela Raguso on October 17, 2019 7:36 pm

      I guys, thank u for this tutorial.
      i’m new user of Python.
      Need to install Python 3.7 on Ubuntu, which version of the OS would you racommend?

      thank for you help

      Reply
    16. Konrad on October 16, 2019 7:00 am

      where exacly I can find the python3.7.4 interpreter

      Reply
    17. mild on October 13, 2019 5:56 am

      very helpful!

      Reply
    18. Rajarajan on October 8, 2019 8:14 pm

      Hi All,

      I m getting the below error while trying to compile python 3.7.4 . I m using openssl version OpenSSL 1.0.2o.

      My config command : ./configure –enable-optimizations –with-ensurepip=install –with-openssl=/usr/local/openssl/

      *** WARNING: renaming “_ssl” since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory
      *** WARNING: renaming “_hashlib” since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory

      Python build finished successfully!
      The necessary bits to build these optional modules were not found:
      _lzma _tkinter _uuid
      readline
      To find the necessary bits, look in setup.py in detect_modules() for the module’s name.

      The following modules found by detect_modules() in setup.py, have been
      built by the Makefile instead, as configured by the Setup files:
      _abc atexit pwd
      time

      Following modules built successfully but were removed because they could not be imported:
      _hashlib _ssl

      Could not build the ssl module!
      Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
      LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381

      Reply
      • Florent Forest on October 15, 2019 9:58 am

        I had the same issue. Solved it by installing the SSL development package (libssl-dev on Mint, probably same on Debian/Ubuntu). Take a look at this SO answer: https://stackoverflow.com/a/44758621/9698048

        Reply
      • Pavol on January 21, 2020 12:09 pm

        Hi RAJARAJAN,
        the problem here is, that openssl must be compiled with CFLAGS=-fPIC, otherwise python won’t compile it.

        Details: https://stackoverflow.com/questions/28234300/usr-local-ssl-lib-libcrypto-a-could-not-read-symbols-bad-value

        Pavol

        Reply
    19. Md. Mazharula Alam Sanvi on October 3, 2019 4:21 pm

      It was very helpful.

      Reply
    20. tony.carman on September 20, 2019 2:50 am

      Good doc. Appears to be a clean install first round through. Thank you for the nice work.

      Reply
    21. SLBasu on September 18, 2019 4:48 pm

      Hi,
      Thanks a lot. I am new to Ubuntu and I did not know that Python 3.6 was already installed in my system. So, can you tell how to uninstall Python 3.7.4? I don’t want to keep too many instances of Python. I am using Ubuntu 18.04.

      Reply
    22. Nadine on September 16, 2019 6:55 pm

      I have successfully downloaded Python 3.7.4 but I am unable to find a way to run the program using Linux Mint.

      Reply
    23. Malcolm on September 13, 2019 11:46 pm

      Your instructions were complete
      It just worked! To Be Honest I am surprised because most Linux stuff doesn’t work quite as advertised.

      Thank you

      Reply
    24. Cormac McClean on September 13, 2019 4:20 pm

      Thanks very much. Working on Ubuntu 16.04 which has Python 3.5 and needed to have 3.7. Very clear instructions.

      Reply
    25. DADA_CHRIS on September 12, 2019 5:39 am

      ModuleNotFoundError: No module named ‘_ctypes’
      make: *** [altinstall] Error 1

      Reply
      • miker on October 8, 2019 1:50 am

        if running on ubuntu 18, mint 19, install dependencies

        sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev

        Reply
    26. Sidney Farias da silva on September 8, 2019 2:55 pm

      Thank you so much, perfect congratulations

      Reply
    27. Ed on September 7, 2019 8:42 pm

      Worked perfectly for me on the first try! Thank you very much!

      Reply
    28. Srujan on September 5, 2019 8:58 am

      Works perfectly. Thank you so much 😀

      Reply
    29. Alex on September 1, 2019 11:08 pm

      I am sorry this method is not working for me; running Linux Mint
      last version. Python 3.4.7 getting the following message:

      zipimport.ZipImportError: can’t decompress data; zlib not available
      Makefile:1142: recipe for target ‘altinstall’ failed
      make: *** [altinstall] Error 1

      Reply
    30. ian on August 31, 2019 1:19 am

      Many thanks for the Python 3.7.4 install instructions.

      Reply
    31. jacks neto on August 30, 2019 10:14 am

      I been trying to find the solution for almost a week had so much trouble, but following your tutorial was a success. keep up the good work.

      Reply
    32. mike lancaster on August 29, 2019 2:25 pm

      Very informative and helped a lot!

      Reply
    33. Jura on August 27, 2019 9:48 am

      Very informative and helped a lot!

      Reply
    34. Matheus on August 22, 2019 9:56 pm

      Obrigado! Você me ajudou muito.

      Reply
    35. SeongYoonHuh on August 22, 2019 3:48 am

      Thankyou for your idea, I really helpful this post.

      Have a nice day!

      Reply
    36. Rajesh Chaudhary on August 15, 2019 3:22 am

      Thanks you. By the way please use pagination or loader for comments. Thanks.

      Reply
      • Rahul on August 15, 2019 6:10 am

        Thanks, Rajesh for your suggestion.

        Reply
    37. Chibuike on August 10, 2019 6:47 pm

      Thanks so much bro. had much difficulties trying to install python but following your steps have eased my stress.

      Reply
    38. abdul on July 22, 2019 12:00 pm

      thank you so much. I’m able to install it on my ec2 instance and get pip3.7 also

      Reply
    39. Connor on July 20, 2019 12:50 pm

      This was really useful, thank you!

      Reply
    40. Ashlon on July 6, 2019 1:20 pm

      I just bought a System76 laptop, running PopOS on it. These steps worked fine on it. Thanks!

      Reply
    41. Gangster on July 6, 2019 6:08 am

      I insatlled it but can anyone tell me how to start it??

      Reply
      • SweLG on July 10, 2019 9:37 pm

        type ‘python’ in terminal
        or, if you have written a python script write ‘python3.7 scriptname.py’ in terminal

        Reply
    42. Mohee Jarada on July 5, 2019 10:26 am

      You are amazing. I did your steps into different Linux distributions of Ubuntu (Linux Mint 18 + Linux Mint 19 + OpenSuse and ElementaryOS) based and worked smoothly. Much appreciated for this excellent post.

      Reply
    43. Adibikar on June 20, 2019 8:31 am

      Hi, i have follow and successfully install python3.7. How do I remove them? Since in “dpkg -l | grep”, python3.7 is not there.

      Reply
    44. Donald L Wilson on June 19, 2019 9:21 am

      Anybody happen to know of a shell script that you could run that would tell you which of your files already installed depend on the earlier version of python. That way you could see just how many of your programs needed to be patched?

      Reply
    45. Vigi on June 6, 2019 9:00 am

      Linux mint 19 all worked. thank

      Reply
    46. Christian Walter on May 31, 2019 8:48 am

      The procedure worked for me, Ubuntu 15.04.
      There were some error notifications upon the command
      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
      yet the rest of the procedure worked out well.
      The compilation was successful and I can use python3.7 alright so far.
      Thank you for your instruction, cheers!

      Reply
    47. shuster oded on May 30, 2019 6:19 am

      very good article Thank you.

      Reply
    48. Benjamin on May 29, 2019 5:27 pm

      Thank you! This worked great for me.

      Reply
    49. Amey on May 29, 2019 3:31 pm

      Thanks, man. It worked like a charm!

      Reply
    50. pee4kotoo on May 26, 2019 8:44 pm

      thanks it helped me

      Reply
    51. Akhil Mathew on May 15, 2019 6:02 pm

      Before installing Python 3.7.3
      just execute this command given below for easy working
      $ sudo apt-get install zlib1g-dev

      Reply
    52. Doug on May 13, 2019 11:29 pm

      Great instructions. But, they are being done without consideration for the existing ‘Python 3.6.7’ that presently exists on the ‘Linux Mint 19.1 Tessa’ working as the primary platform? There won’t be confusion in regard to anything to do w/python3 then?

      Reply
    53. ori on May 10, 2019 10:24 pm

      thanks

      Reply
    54. Hamilo on May 10, 2019 10:10 am

      Please help!

      (python-may2019) [email protected]:~/programowanie$ pip install jupyter
      pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
      Collecting jupyter
      Cache entry deserialization failed, entry ignored
      Could not fetch URL https://pypi.python.org/simple/jupyter/: There was a problem confirming the ssl certificate: Can’t connect to HTTPS URL because the SSL module is not available. – skipping
      Could not find a version that satisfies the requirement jupyter (from versions: )
      No matching distribution found for jupyter

      Reply
      • Kamrul on July 25, 2019 1:28 pm

        Same here.

        Reply
    55. Diego Graf on May 9, 2019 10:36 pm

      thanks, it worked for me!

      Reply
    56. Bhagesh Pant on May 6, 2019 5:59 am

      Hi @Rahul_Kumar,

      Thanks for contributing this great article. The output throws a Build error while compiling python source within ‘$ sudo make altinstall’.

      Just want to fork an edit for a successful installation on Ubuntu (18.04 or other).

      It works neatly if you add another LOC within STEP-1 (Prerequisites) as stated under, rest assured installation will be successful.

      $sudo apt-get install libffi-dev

      *** STEP-1 : Prerequisites ***
      $ 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
      $ sudo apt-get install libffi-dev

      Reply
    57. Fabiano Duarte on May 5, 2019 4:28 pm

      Oh, thanks! It works in my Linux machine.

      Reply
    58. Siva S on May 4, 2019 5:10 am

      sudo apt-get install libffi-dev

      Reply
    59. JOHN on April 16, 2019 3:16 pm

      Follow the steps to the T and it works well.

      Reply
    60. Afzal S H on April 4, 2019 7:15 am

      I needed to install two additional packages; `zlib1g-dev` and `libffi-dev`

      Reply
    61. luiz on March 29, 2019 9:23 pm

      Thank you for helping me a lot ..

      Reply
    62. Martin von Slawinski on March 24, 2019 10:19 am

      Great article. Worked neatly. THank you

      Einen Gruß aus Deutschland!!!!! (Germany)

      LG, Martin

      Reply
    63. chirag on March 19, 2019 7:10 am

      I have this error when i use python3.7 for create virtual enviorment.

      GNU nano 2.9.3 /var/log/apache2/rpg-tukunang-siteminder.log

      [Tue Mar 19 06:56:20.910728 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/db/models/aggregates.py”, line 5, in
      [Tue Mar 19 06:56:20.910731 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django.db.models.expressions import Case, Func, Star, When
      [Tue Mar 19 06:56:20.910737 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/db/models/expressions.py”, line 7, in
      [Tue Mar 19 06:56:20.910740 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django.db.models import fields
      [Tue Mar 19 06:56:20.910749 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/db/models/fields/__init__.py”, line 11, in
      [Tue Mar 19 06:56:20.910752 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django import forms
      [Tue Mar 19 06:56:20.910757 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/forms/__init__.py”, line 6, in
      [Tue Mar 19 06:56:20.910761 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django.forms.boundfield import * # NOQA
      [Tue Mar 19 06:56:20.910766 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/forms/boundfield.py”, line 4, in
      [Tue Mar 19 06:56:20.910769 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django.forms.widgets import Textarea, TextInput
      [Tue Mar 19 06:56:20.910775 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/forms/widgets.py”, line 21, in
      [Tue Mar 19 06:56:20.910778 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from .renderers import get_default_renderer
      [Tue Mar 19 06:56:20.910783 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/forms/renderers.py”, line 11, in
      [Tue Mar 19 06:56:20.910786 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from django.template.backends.jinja2 import Jinja2
      [Tue Mar 19 06:56:20.910792 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/django/template/backends/jinja2.py”, line 1, in
      [Tue Mar 19 06:56:20.910795 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] import jinja2
      [Tue Mar 19 06:56:20.910800 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/jinja2/__init__.py”, line 82, in
      [Tue Mar 19 06:56:20.910804 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] _patch_async()
      [Tue Mar 19 06:56:20.910809 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/jinja2/__init__.py”, line 78, in _patch_async
      [Tue Mar 19 06:56:20.910812 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from jinja2.asyncsupport import patch_all
      [Tue Mar 19 06:56:20.910818 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/jinja2/asyncsupport.py”, line 13, in
      [Tue Mar 19 06:56:20.910821 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] import asyncio
      [Tue Mar 19 06:56:20.910826 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/usr/lib/python3.6/asyncio/__init__.py”, line 21, in
      [Tue Mar 19 06:56:20.910830 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from .base_events import *
      [Tue Mar 19 06:56:20.910835 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/usr/lib/python3.6/asyncio/base_events.py”, line 17, in
      [Tue Mar 19 06:56:20.910838 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] import concurrent.futures
      [Tue Mar 19 06:56:20.910843 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/concurrent/futures/__init__.py”, line 8, in
      [Tue Mar 19 06:56:20.910849 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] from concurrent.futures._base import (FIRST_COMPLETED,
      [Tue Mar 19 06:56:20.910863 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] File “/var/www/sm/python/lib/python3.7/site-packages/concurrent/futures/_base.py”, line 381
      [Tue Mar 19 06:56:20.910871 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] raise exception_type, self._exception, self._traceback
      [Tue Mar 19 06:56:20.910889 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] ^
      [Tue Mar 19 06:56:20.910897 2019] [wsgi:error] [pid 29306:tid 139714993866496] [remote 188.114.102.126:28470] SyntaxError: invalid syntax

      Reply
    64. Lu on March 4, 2019 3:09 am

      Hey, How do you reverse/delete the entire install?

      Reply
    65. Peter Sanza on March 3, 2019 2:45 pm

      Two comments:

      1) I find it bad form to build as root. If the build fails (as it did for me) you have a mess to clean up with files/folders owned by root. The Makefile is designed (and intended) to build and test python as an unprivileged user in an unprivileged folder. Only the final step (make altinstall) needs to run as super user.

      2) You might have missed a dependency. My build failed on _ctype module. Although this is listed as an optional module and the build process continues after acknowledging the failure, the build ultimately fails during final installation while pre-compiling the python library. So the python library only gets partially installed and leaves quite the mess to clean up. So maybe it is not so optional? Add “libffi-dev” to the list of libraries to install prior to building. Once I added it, the install went smoothly.

      Reply
    66. Manuel on March 1, 2019 4:02 pm

      Great article. Worked neatly. THank you

      Reply
    67. sthon on February 26, 2019 9:19 pm

      gracias parce, me fue de mucha utilidad… lastima no tener pa invitarlo a una cerveza…

      Reply
    68. Basak on February 26, 2019 2:46 pm

      I need to run Selenium using Python 3.7 on Ubuntu 18.04. Since with above steps Python 3.7 libs gets installed in /usr/local/bin not in /usr/bin, on installation of selenium , selenium binaries compatible with Python 2.7 libs gets installed on running below command:

      sudo pip install selenium .

      Isn’t it be a better idea to install Python3.7 as proper install in /usr/bin instead of alternate install like above?

      Reply
      • Peter Sanza on March 3, 2019 2:50 pm

        “make altinstall” intentionally installs in the alternate directory to preserve your distribution’s default python in the “normal” place. If you use “make install” instead, this will install the new python in the normal place replacing the default one that came with your distribution. HOWEVER, it is VERY LIKELY you will break several things in your distribution that depend on the version of python that came with your distribution. Use at your own risk.

        Reply
        • davidm on January 2, 2021 6:18 pm

          I posted a comment before I saw this reply:
          I have a 16.04 version of Ubuntu which comes with python 3.5. I am not a python guy at all but I need python 3.7 to run an application. I would like to replace 3.5 with 3.7 in /usr/bin. The instructions on this page for downloading and creating python 3.7 seemed to work perfectly (thanks so much for that). However, I need 3.7 to be my default python3 version. I tried using ‘make install’ instead of ‘make altinstall’ to no effect. How do I do this?
          Regards.

          Reply
    69. aldrin monteiro on February 26, 2019 2:16 pm

      Very good. You save me

      Reply
    70. Andreas on February 21, 2019 1:08 pm

      I follow all the instructions as given but I get this error when I do
      sudo make altinstal

      from _ctypes import Union, Structure, Array
      ModuleNotFoundError: No module named ‘_ctypes’
      Makefile:1140: recipe for target ‘altinstall’ failed
      make: *** [altinstall] Error 1

      Reply
      • Peter Sanza on March 3, 2019 2:51 pm

        See my post how to solve this.

        Reply
    71. Rob on February 11, 2019 6:45 pm

      Worked like a charm except i had to run `$ apt-get install libffi-dev` due to the build failing…may want to add to your notes. Thanks.

      Reply
    72. Robert on February 9, 2019 4:56 pm

      When I try to build with pip I get this error.

      ./configure –enable-optimizations –with-ensurepip=install
      sudo make altinstall

      What does it mean?

      Exception:
      Traceback (most recent call last):
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/base_command.py”, line 143, in main
      status = self.run(options, args)
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_internal/commands/install.py”, line 259, in run
      with self._build_session(options) as session:
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/base_command.py”, line 79, in _build_session
      insecure_hosts=options.trusted_hosts,
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_internal/download.py”, line 337, in __init__
      self.headers[“User-Agent”] = user_agent()
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_internal/download.py”, line 100, in user_agent
      zip([“name”, “version”, “id”], distro.linux_distribution()),
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 120, in linux_distribution
      return _distro.linux_distribution(full_distribution_name)
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 675, in linux_distribution
      self.version(),
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 735, in version
      self.lsb_release_attr(‘release’),
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 892, in lsb_release_attr
      return self._lsb_release_info.get(attribute, ”)
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 550, in __get__
      ret = obj.__dict__[self._fname] = self._f(obj)
      File “/tmp/tmp24wspe96/pip-18.1-py2.py3-none-any.whl/pip/_vendor/distro.py”, line 998, in _lsb_release_info
      stdout = subprocess.check_output(cmd, stderr=devnull)
      File “/home/robert/src/Python-3.7.2/Lib/subprocess.py”, line 395, in check_output
      **kwargs).stdout
      File “/home/robert/src/Python-3.7.2/Lib/subprocess.py”, line 487, in run
      output=stdout, stderr=stderr)
      subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.
      Makefile:1140: recipe for target ‘altinstall’ failed
      make: *** [altinstall] Error 2

      Reply
    73. HubertHarbus on February 9, 2019 12:16 am

      I’m doing all that and in the end I’m still getting:

      [email protected]:/usr/src/Python-3.7.2 $ python3 –version
      Python 3.5.3

      It seems 3.7.2 didn’t get installed correctly??

      Reply
      • Yash on February 12, 2019 4:49 pm

        try this,
        $ python3.7 –version

        Reply
    74. sam on February 1, 2019 5:40 am

      works beautifully on Mint 19.1

      Reply
    75. Mike on January 31, 2019 2:24 am

      Big thankyou!

      Reply
    76. Oseias D. Farias on January 12, 2019 5:47 pm

      Thank You!

      Reply
    77. Alex on December 17, 2018 4:53 am

      Hi Rahul, this is what i get when i type “cd Python3.7.1”:

      bash: cd: Python3.7.1: No such file or directory

      Reply
      • Alex on December 20, 2018 9:28 pm

        Never mind, fixed it.

        Reply
    78. daniele on December 13, 2018 8:49 am

      Hi Rahul, many thanks for your support,.
      I successfully installed Python 3.7.1 , but it works just on the terminal.
      Because I’m beginner I wish to use an easier interface: How can I install an IDE on my desktop?
      many Thanks.
      BR
      Daniele

      Reply
      • Rahul on December 13, 2018 9:51 am

        You can use Visual Studio Code IDE

        Reply
        • Kyle on January 5, 2019 12:35 am

          Also, check out this for using python with vscode:
          https://code.visualstudio.com/docs/languages/python

          Reply
    79. bnvmn on December 9, 2018 6:46 pm

      Stuped article. Now i not use python…. samples crashed!!!

      Reply
    80. Rahul V on December 7, 2018 12:42 pm

      Hi ,

      When I follow the instruction , python3.7 is getting installed in usr/local/bin and not in usr/bin where other python versions are installed .
      Thus I have two questions

      1) Is it supposed to be installed at usr/bin or usr/local/bin ?
      2)when I use the command :
      ***
      virtualenv -p /usr/local/bin/python3.7 py37_test1
      ****
      to create a virtual env using python 3.7 , i get the following error :
      *****************
      Running virtualenv with interpreter /usr/local/bin/python3.7
      Using base prefix ‘/usr/local’
      New python executable in /home/rahul/py37_test1/bin/python3.7
      Also creating executable in /home/rahul/py37_test1/bin/python
      Installing setuptools, pip, wheel…

      Complete output from command /home/rahul/py37_test1/bin/python3.7 – setuptools pip wheel:
      Traceback (most recent call last):
      File “”, line 8, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/__init__.py”, line 40, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py”, line 8, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py”, line 12, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/commands/__init__.py”, line 6, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/commands/completion.py”, line 6, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/base_command.py”, line 18, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/download.py”, line 38, in
      File “/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py”, line 3, in
      File “/usr/local/lib/python3.7/ctypes/__init__.py”, line 7, in
      from _ctypes import Union, Structure, Array
      ModuleNotFoundError: No module named ‘_ctypes’

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File “”, line 11, in
      ImportError: cannot import name ‘main’ from ‘pip’ (/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-18.1-py2.py3-none-any.whl/pip/__init__.py)
      —————————————-
      …Installing setuptools, pip, wheel…done.
      Traceback (most recent call last):
      File “/usr/local/lib/python2.7/dist-packages/virtualenv.py”, line 2462, in
      main()
      File “/usr/local/lib/python2.7/dist-packages/virtualenv.py”, line 762, in main
      symlink=options.symlink,
      File “/usr/local/lib/python2.7/dist-packages/virtualenv.py”, line 1015, in create_environment
      install_wheel(to_install, py_executable, search_dirs, download=download)
      File “/usr/local/lib/python2.7/dist-packages/virtualenv.py”, line 968, in install_wheel
      call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
      File “/usr/local/lib/python2.7/dist-packages/virtualenv.py”, line 854, in call_subprocess
      raise OSError(“Command {} failed with error code {}”.format(cmd_desc, proc.returncode))
      OSError: Command /home/rahul/py37_test1/bin/python3.7 – setuptools pip wheel failed with error code 1

      **********

      How can I create a virtual env using python3.7

      Reply
      • José Luís Silva on January 31, 2019 2:25 pm

        Hi,
        Same problem here, if someone knows how to fix this, it would be very helpful

        Reply
        • Ricardo on February 12, 2019 9:41 am

          sudo apt-get install libffi-dev (on Debian)

          Segura no puta merda e vai com fé, jovem padawan! haha

          Reply
          • Ankush on February 18, 2019 10:45 am

            Hi,
            I want to know the same command for ubuntu

            Reply
    81. Someguy on November 26, 2018 3:55 pm

      Thanks for this. I had to ‘sudo apt-get install libffi-dev’ as well to make the install complete without errors, missed ctypes module otherwise.

      Reply
      • Fabio on December 7, 2018 12:04 am

        Many thanks mate!

        Reply
    82. Don on October 17, 2018 3:25 pm

      When I enter: wget wget https://www.python …… etc I get message:
      permission denied
      and
      cannot write to python-3.7.0.tgz(success).

      Reply
      • Darren Haynes on October 22, 2018 7:52 pm

        Its a typo. The line should start with “sudo wget”, not “wget wget”.

        Reply
        • Rahul K. on October 23, 2018 3:35 am

          Thanks, Darren

          I have corrected the typo.

          Reply
    83. gatopeich on October 11, 2018 9:08 am

      You should not use “sudo” except perhaps for the final installation command.

      Reply
    84. Orr on September 19, 2018 1:27 pm

      Awesome instructions, straight and to the point. I would only add for beginners ‘you need to be a bit patient while doing ‘sudo make altinstall’.`

      Reply
    85. nikolay on September 2, 2018 1:41 am

      Python 2.7.15rc1
      and i get this when I run python -V or python –version

      Reply
      • Alex on December 17, 2018 4:51 am

        try using python3 -V

        Reply
    86. nikolay on September 2, 2018 1:38 am

      The directory ‘/home/nikolay/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
      The directory ‘/home/nikolay/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

      what does this means?

      Reply
    87. jacobo on August 24, 2018 3:33 pm

      muchas gracias instalación satisfactoria en instancia de google cloud debían 9 muy buen tutorial

      Reply
    88. Douglas on August 14, 2018 4:03 am

      Didn’t work here…
      The following error appears at the end of the ‘sudo make altinstall’:

      ModuleNotFoundError: No module named ‘_ctypes’
      Makefile:1132: recipe for target ‘altinstall’ failed
      make: *** [altinstall] Error 1

      Reply
      • Antoni M on August 19, 2018 4:57 pm

        I had the same error. Works with:

        sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev

        or

        sudo apt-get install libffi-dev

        https://bugs.python.org/issue31652

        Reply
    89. Maurizio on August 12, 2018 10:33 am

      Thank you very much. i installed python3.7 in mint 19 Tara successfully

      Reply
    90. Namiam on January 16, 2018 4:00 pm

      I installed successfully on Linux Mint 18.3
      Thanks and highly appreciate.

      Reply
    91. unkb on May 24, 2017 10:41 pm

      HTTP request sent, awaiting response… 200 OK
      Length: 19611207 (19M) [application/octet-stream]
      Python-3.4.5.tgz: Permission denied

      Cannot write to ‘Python-3.4.5.tgz’ (Success).

      help?

      Reply
      • Rahul K. on May 26, 2017 4:01 am

        HI UNKB,

        It looks you have the issue with write on your system. Try to download the file in some other directory like /tmp

        Reply
      • edgar on October 26, 2017 6:48 pm

        try adding “sudo” at the beggining. it work for me.

        Reply
        • anil on November 30, 2017 10:41 pm

          thanks it worked for me too

          Reply
    92. Gaurav S on December 6, 2016 2:47 pm

      Hey,

      The tutorial is easy enough to follow, and I went till the following command:
      sudo make altinstall
      But it goes into an infinite loop, and it never ends.
      Actually the following line keep appearing after 2-3 min :
      /bin/sh ./configure
      PS: I’m trying to install it in Debian(wheezy) in beaglebone black.

      Thanks

      Reply
    93. xhoi on May 2, 2016 5:10 pm

      I can’t check the python version

      Reply
      • Suraj Tripathi on July 19, 2016 12:59 pm

        use this:
        python -V

        Reply
    94. Dan on April 12, 2016 2:42 am

      Thanks Rahul,

      Very easy to follow instructions. Note to self: if at first it doesn’t work, sudo it and try again 🙂

      Thanks again.

      Reply
      • DIMASPUTRA on June 14, 2016 12:15 pm

        dimas[email protected]:/usr/src$ sudo tar xzf Python-3.4.4.tgz
        tar (child): Python-3.4.4.tgz: Cannot open: No such file or directory
        tar (child): Error is not recoverable: exiting now
        tar: Child returned status 2
        tar: Error is not recoverable: exiting now

        Reply
        • niunj on September 4, 2018 12:31 am

          nigger

          Reply
          • Kom on July 31, 2019 8:17 am

            I am new to Linux..I followed every single step of yours, but now iam not getting the command to open my python as a usr…

            Reply
    95. Mirek on March 11, 2016 1:45 am

      Grate example how to install python. One small detail…. you can’t highlight the text in black windows and copy in to terminal. Every thing need to be retyped.
      Can you review that article and just place the comments as regular text?

      Regards.

      Reply
    96. Dan on February 24, 2016 1:24 am

      Thanks for the well explained instructions. I only had trouble extracting the tar but added sudo and everything worked as it should.

      Thanks again

      Reply
    97. G.G. on January 28, 2016 7:47 pm

      Hi Rahul:

      Thank you for your easy to follow tutorial. I get this response:

      The directory ‘/home/xxxxx/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

      The directory ‘/home/xxxxx/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

      after entering: sudo make altinstall

      I’m a newbie to Linux (Lubuntu) and Python. Please help. Thank you.

      BTW, the OS came with python 2.7.6 installed. Can/do I remove it, if so how?

      Reply
    98. Phillip on November 20, 2015 4:32 pm

      Does replacing Python 2.7 with Python 3.X in /usr/bin/python affect my system in anyway negatively

      Reply
      • Teo on March 20, 2019 5:55 pm

        YES, it will break your system.

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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