1. Download Python-3.6.1.tar.xz from
https://www.python.org/2. Unzip the file and keep the folder in home directory.
3. Open terminal in that directory and perform the following commands:
./configure
make
make test
sudo make install
4. This will install Python 3.6 but pip3 may not be working.Install necessary modules using:
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
5. Now write the following to re run the installation:
sudo make
sudo make install
6. Now you can install packages with Python 3.6 using pip3 command. For example:
sudo pip3 install numpy