How to make iPython use Python 2 instead of Python 3

Less intrusive solution(as my solution below does not need changing any library files) to this problem is

python2.7 -m IPython notebook

so the general command is

{{python-you-want-ipython-to-use}} -m IPython notebook

Why will this work ?

Because if you see the ipython script (/usr/local/bin/ipython) it seems to be a python script by itself and it has the shebang (#!/usr/bin/python3), so the ipython is not a standalone binary, but it gets life because of some python. So as that ipython script itself needs some python to run it, so you run the ipython module directly using some python of your choice instead of letting that /usr/local/bin/ipython to decide it for you, and that is the fix for the problem of ‘what python ipython uses’.


Following ipython reads wrong python version, in /usr/local/bin/ipython, I simply changed

#!/usr/bin/python3

in the first line to

#!/usr/bin/python

and Python 2 has become the default version used by iPython:

kurt@kurt-ThinkPad:~$ ipython
Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

now IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2. When using Python 2.7, please install IPython 5.x LTS Long Term Support version.

Beginning with IPython 6.0, Python 3.3 and above is required.