install Python3.6.8 to ubuntu

## Introduction
Probably most popular version of Python is '3.6.x'. I'm explain this version.
## confirm version already installed Python on ubuntu 16.04LTS
```shell:bash
$ python3.5 -V
```
```shell:bash
python3.5.2
```
## install Python3 'deb' libraries
### necessary 'deb' libraries list
|library name|use|
|------------|---|
|build-essential|building Python on ubuntu|
|python3-dev|Python3 developer tools|
|libsqlite3-dev|SQLite3 library|
|libreadline6-dev|readline Python module|
|libgdbm-dev|dbm.gnu Python module|
|zlib1g-dev|zlib Python module|
|libbz2-dev|bz2 Python module|
|sqlite3|sqlite3 Python module|
|tk-dev|tkinter Python module|
|zip|zip Python module|
|libssl-dev|ssl Python module|

### command for Python3 'deb' libraries install on ubuntu
```shell:bash
$ sudo apt -y install build-essential
$ sudo apt -y install python3-dev
$ sudo apt -y install libsqlite3-dev
$ sudo apt -y install libreadline6-dev
$ sudo apt -y install libgdbm-dev
$ sudo apt -y install zlib1g-dev
$ sudo apt -y install libbz2-dev
$ sudo apt -y install sqlite3
$ sudo apt -y install tk-dev
$ sudo apt -y install zip
$ sudo apt -y install libssl-dev
```
or only 1 line command below.

```shell:bash
$ sudo apt-get -y install build-essential python3-dev  libsqlite3-dev libreadline6-dev libgdbm-dev zlib1g-dev libbz2-dev sqlite3 tk-dev zip libssl-dev 
```
If proxy server over from local LAN then you must add proxy setting parameter to command

```shell:bash
$ sudo apt -y -o Acquire::http::proxy="http://username:password@proxy.hoge.domain.name:portno/" install build-essential
```
## build new version 'Python3.6.8' from source files
If other versions of python are same operations available. By the way, recent version is '3.8.0' at 15, March 2019.
## proxy setting if ubuntu server connect to internet via from proxy server

```shell:bash
$ sudo vim /etc/wgetrc
```
+ add 3 lines blow

```shell:bash
http_proxy=http://user id:password@proxy.xxx.xxx:port no/
https_proxy=http://user id:password@proxy.xxx.xxx:port no/
ftp_proxy=user id:password@proxy.xxx.xxx:port no/
```

## ftp download compression file 'Python-3.6.8.tgz' from source files
```shell
$ wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
```
```shell
--2019-03-12 14:01:20--  https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
www.python.org (www.python.org) をDNSに問いあわせています... 151.101.88.223, 2a04:4e42:15::223
www.python.org (www.python.org)|151.101.88.223|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 22710891 (22M) [application/octet-stream]
`Python-3.6.8.tgz' に保存中

Python-3.6.8.tgz                             100%[==============================================================================================>]  21.66M  13.2MB/s    時間 1.6s

2019-03-12 14:01:22 (13.2 MB/s) - `Python-3.6.8.tgz' へ保存完了 [22710891/22710891]
```
### extract Python-3.6.8.tgz to './Python-3.6.8' directory
```shell:bash
$ tar xf Python-3.6.8.tgz
$ ll
```
```shell:bash
合計 22224
drwxr-xr-x  5 vagrant vagrant     4096  3月 12 14:05 ./
drwxr-xr-x  4 root    root        4096  3月  9 18:20 ../
-rw-------  1 vagrant vagrant      211  3月 11 13:48 .bash_history
-rw-r--r--  1 vagrant vagrant      220  3月  8 08:21 .bash_logout
-rw-r--r--  1 vagrant vagrant     3796  3月  9 18:55 .bashrc
drwx------  2 vagrant vagrant     4096  3月  9 18:20 .cache/
-rw-r--r--  1 vagrant vagrant      655  3月  8 08:21 .profile
drwx------  2 vagrant vagrant     4096  3月  9 18:20 .ssh/
-rw-------  1 vagrant vagrant     1050  3月 10 02:38 .viminfo
-rw-rw-r--  1 vagrant vagrant      171  3月 12 14:01 .wget-hsts
drwxr-xr-x 16 vagrant vagrant     4096 12月 19  2017 Python-3.6.8/
-rw-rw-r--  1 vagrant vagrant 22710891 12月 19  2017 Python-3.6.8.tgz
```
### create 'Makefile' by configure script

#### change directory
```shell:bash
$ cd Python-3.6.8/
$ pwd
```
```shell:bash
/home/vagrant/Python-3.6.8
```
#### create 'Makefile' for target directory '/opt/python3.6.8' 
```shell:bash
$ ./configure --prefix=/opt/python3.6.8
```
```shell:bash
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
...................
.....Omission......
...................
creating Modules/Setup.local
creating Makefile

If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations
```
### confirm existing 'Makefile'
```shell:bash
$ ll Makefile
```
```shell:bash
-rw-rw-r-- 1 vagrant vagrant 69199  3月 12 14:12 Makefile
```
### compile in order to 'Makefile'
```shell:bash
$ make
```
```shell:bash
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
...................
.....Omission......
...................
# Replace makefile compat. variable references with shell script compat. ones;  ->
LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
# On Darwin, always use the python version of the script, the shell
# version doesn't use the compiler customizations that are provided
# in python (_osx_support.py).
if test `uname -s` = Darwin; then \
        cp python-config.py python-config; \
fi
```

### test Makefile
```shell:bash
$ sudo make test
```

### install Python3.6.8 in order to 'install' session in 'Makefile'
```shell:bash
$ sudo make install
```
```shell
Creating directory /opt/python3.6.8/bin
Creating directory /opt/python3.6.8/lib
if test "no-framework" = "no-framework" ; then \
        /usr/bin/install -c python /opt/python3.6.8/bin/python3.6m; \
else \
        /usr/bin/install -c -s Mac/pythonw /opt/python3.6.8/bin/python3.8m; \
fi
...................
.....Omission......
...................
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
```
### confirm installed Python3.6.8 version
```shell
$ /opt/python3.6.8/bin/python3.6 -V
```
```shell
Python 3.6.8
```
### create symbolic link 'python3.8'
```shell
$ sudo ln -s /opt/python3.8.4/bin/python3.8 /usr/local/bin/python3.8
```
### confirm symbolic link command 'python3.6'
```shell
$ python3.6 -V
```
```shell
Python 3.6.8
```
### create symbolic link 'pip'
```shell
$ sudo ln -s /opt/python3.6.8/bin/pip3.6 /usr/local/bin/pip
```
### confirm symbolic link command 'pip'
```shell:bash
$ pip --version
```
```shell:bash
pip 18.1 from /opt/python3.6.8/lib/python3.6/site-packages/pip (python 3.6)
```