How to install Python 3.6 on Ubuntu 19.04?
It is not necessary to compile from source, just download and install deb-packages python 3.6 with dependencies manually:
wget http://archive.ubuntu.com/ubuntu/pool/main/p/python3.6/libpython3.6-minimal_3.6.7-1~18.10_amd64.deb
dpkg -i libpython3.6-minimal_3.6.7-1~18.10_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/p/python3.6/libpython3.6-stdlib_3.6.7-1~18.10_amd64.deb
dpkg -i libpython3.6-stdlib_3.6.7-1~18.10_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/p/python3.6/python3.6-minimal_3.6.7-1~18.10_amd64.deb
dpkg -i python3.6-minimal_3.6.7-1~18.10_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/p/python3.6/python3.6_3.6.7-1~18.10_amd64.deb
dpkg -i python3.6_3.6.7-1~18.10_amd64.deb
This is enough to run python 3.6. However, some modules may not work, such as pycurl, in result I have not found a solution. ModuleNotFoundError occurs while trying to import, ImportError error occurs when trying to install pycurl: cannot import name 'sysconfig' because the python3-distutils package is installed from version 3.7 and is incompatible. Manual installation from 3.6 breaks the dependencies of version 3.7 and in any case apt will try to fix it.
Don't mess around in your system.
Ubuntu 19.04 as Python 3.7 as given standard so if you want to work with Python 3.6.*, you should install conda and create an environment with the specific Python version:
conda create --name py36 -c conda-forge python=3.6.* pip
For sure you could also create an other virtual environment and use pip.
Or you could go to docker.
On Linux / macOS you could use nix like
nix-env -iA nixpkgs.python37
to enter an environment that has e.g. in this case Python3.7 (for sure you can change the version)
or as a very good Python (advanced) environment you can use mach-nix (with nix) like
mach-nix env ./env -r requirements.txt
(which even supports conda [but currently in beta])
or via api like
nix-shell -p nixFlakes --run "nix run github:davhau/mach-nix#with.ipython.pandas.seaborn.bokeh.scikit-learn "
If you really want to change the version on the operating system then I would recommend to use NixOS.
Yes as @furas says you can download the source of python 3.6.8 or 3.6.7 (these are direct link of .xz source files if you want in another format, visit 3.6.8 or 3.6.7)
these are some contents from the README.rst
file of the source
Build Instructions
------------------
On Unix, Linux, BSD, macOS, and Cygwin::
./configure
make
make test
sudo make install
This will install Python as python3.
If you want python3.6 install as python3.6(not python3) in your system here are some other guide lines in README.rst
file
For example, if you want to install Python 2.7, 3.5, and 3.6 with 3.6 being the
primary version, you would execute ``make install`` in your 3.6 build directory
and ``make altinstall`` in the others.
Thanks...