Install Python3.7.2

Install Phthon3.7.2 and make symlink to /usr/bin/.

Install dependence

$ sudo apt update
$ sudo apt install build-essential python-dev python-setuptools python-pip python-smbus build-essential libncursesw5-dev libgdbm-dev libc6-dev zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libffi-dev

Download and install Python-3.7.2

$ wget
$ tar zxvf Python-3.7.2.tgz && cd Python-3.7.2
$ sudo ./configure --prefix=/usr/local/opt/python-3.7.2 --with-ssl
$ sudo make && sudo make install


In the 3rd command, param --with--ssl is important, don’t miss it!

Rename lsb_release if there is a error


$ $ pip3 list
Package    Version
---------- -------
pip        10.0.1
setuptools 39.0.1
Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_internal/", line 246, in main
    return command.main(cmd_args)
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_internal/", line 264, in main
    timeout=min(5, options.timeout)) as session:
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_internal/", line 81, in _build_session
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_internal/", line 338, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_internal/", line 101, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 120, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 634, in linux_distribution
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 688, in version
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 836, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 522, in __get__
     ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/pip/_vendor/", line 933, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/local/opt/python-3.7.2/lib/python3.7/", line 389, in check_output
  File "/usr/local/opt/python-3.7.2/lib/python3.7/", line 481, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

Rename it safely:

$ sudo mv /usr/bin/lsb_release /usr/bin/lsb_release_back

Then, try again:

$ pip3 list
Package    Version
---------- -------
pip        10.0.1
setuptools 39.0.1
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Upgrade pip3

Do it:

$ pip3 install -U pip
Looking in indexes:,
Collecting pip
  Downloading (1.3MB)
    100% |████████████████████████████████| 1.3MB 43kB/s
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1

Check it:

$ pip3 list
Package    Version
---------- -------
pip        18.1
setuptools 39.0.1


May update setuptools:

$ sudo pip3 install -U setuptools
Looking in indexes:,
Collecting setuptools
  Downloading (573kB)
    100% |████████████████████████████████| 573kB 20kB/s
Installing collected packages: setuptools
  Found existing installation: setuptools 39.0.1
    Uninstalling setuptools-39.0.1:
      Successfully uninstalled setuptools-39.0.1
Successfully installed setuptools-40.6.3

Python3 is ready now, well done!