Install Python 3.7.0 on Linux
by joe

Posted on 2018-09-23

It used to be that installing Python3 from source code onto a Linux system did not change much from one version to the next. We have done full source code installs for Python several times over the last few years. We ran through the full installation process for Python 3.6.4 multiple times in preparing for this post several months ago.

That changed with Python 3.7 - mostly because Python 3.7 requires an OpenSSL package version that does not suffer from missing X509_VERIFY_PARAM_set1_host() support.

It took a bit of research, but these instructions now work consistently for us.


NOTE: As of January 28, 2019, these same instructions work for installing Python 3.7.1 but NOT for installing Python 3.7.2.

Prior to starting the Python install proper, we need to install a full set of supporting packages. The set of packages shown below is sufficient to support the Python 3.7 installation.

$ sudo apt-get install build-essential checkinstall python3-dev
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev
$ sudo apt-get install libssl-dev libsqlite3-dev tk-dev 
$ sudo apt-get install libgdbm-dev libc6-dev libbz2-dev
$ sudo apt-get install libffi-dev openssl 

Before doing the install, let's see what Python(s) are included with the basic Ubuntu 16.04. Use the "which -a" command to see all installations of a package. This shows that we do not have either a "python" or a "python2" installation, but we do have a "python3" installation under the /usr/bin directory - the now-standard Ubuntu Python 3.5.2.

$ which -a python
$ which -a python2
$ which -a python3

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.


We get the specific version of Python from the website by downloading it into a temporary directory. (Once the installation is complete, we'll delete the temporary directory.)

NOTE: changing all "3.7.0" to "3.7.1" below works as well.

$ wget

Extract the installation files from the downloaded .tgz file. The "tar xf ..." command creates a subdirectory under our temporary directory (~/tmp/Python-3.7.0). We execute the installation steps from that directory.

$ tar xf Python-3.7.0.tgz
$ cd Python-3.7.0
$ ./configure
$ make
$ make test
$ sudo make install

The "./configure" step only takes about a minute. (Running from an LXC installation, we actually had to do an installs of "gcc" and "make" first, but that only took a minute or so itself.)

The "make" step took only about five minutes on an Ubuntu 16.04 LXC virtual machine configured with 4 Gb memory and 2 CPUs. The successful completion of the "make" step is shown below:

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

The "make test" step runs for almost 16 minutes. See the report of success below:

== Tests result: SUCCESS ==

401 tests OK.

14 tests skipped:
    test_devpoll test_gdb test_kqueue test_lzma test_msilib
    test_ossaudiodev test_startfile test_tix test_tk test_ttk_guionly
    test_winconsoleio test_winreg test_winsound test_zipfile64

Total duration: 15 min 41 sec
Tests result: SUCCESS

The final step is "sudo make install". We have run the installation multiple times and always get the same results concerning the pip installation.

The directory '/home/joe/.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/joe/.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.
Looking in links: /tmp/tmp3nc_ehwv
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

Now we check the Python installations. And confirm that the 3.7 installation is the default.

$ which -a python
$ which -a python3

$ python3
Python 3.7.0 (default, Sep 22 2018, 10:05:13)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.


$ ls -al /usr/local/bin/pyth*
lrwxrwxrwx 1 root root        9 Sep 24 14:31 /usr/local/bin/python3 -> python3.7
-rwxr-xr-x 2 root root 13775472 Sep 24 14:35 /usr/local/bin/python3.7
lrwxrwxrwx 1 root root       17 Sep 24 14:31 /usr/local/bin/python3.7-config -> python3.7m-config
-rwxr-xr-x 2 root root 13775472 Sep 24 14:35 /usr/local/bin/python3.7m
-rwxr-xr-x 1 root root     3097 Sep 24 14:36 /usr/local/bin/python3.7m-config
lrwxrwxrwx 1 root root       16 Sep 24 14:31 /usr/local/bin/python3-config -> python3.7-config
Antsle Installation
The Antlse is great. We spent several days putting this post together. We would spin up a new Ubuntu 16.04 KVM, update and upgrade, then run through a Python installation.

Several of the installs failed, so we deleted the Ubuntu instance and started over. After we found the successful formula, we repeated the installation with variations several times.
As mentioned earlier, these instructions for Python 3.7 are different from earlier releases of Python 3. Locating a correct set of packages to support the installation took a bit of searching. The collection of Ubuntu packages shown in this post by Manivannan Murugave put me over the hump.

One difference: The final instruction step in Manivannan Murugave's post is "sudo make altinstall", which yields an executable that is named "python3.7".


It will be some time yet before we get a comments section working here. In the meantime feel free to send comments via email. On this site our name is Joe Python. The email address is our first name at

Edited: 2019-01-30 20:55:12(utc) Generated: 2019-06-10 17:29:58(utc)