Ipython is using python 3.5 instead of 2.7
I recently update my system from 15.10 to 16.04 but now I'm having a problem with the interpreter used by ipython.
Now ipython a ipython3 uses the same version (3.5.1)
I have tried reinstalling ipython but the problem persist.
Here are the versions reported by the console:
$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> $ python3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> $ ipython
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
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.$ ipython3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
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. 5 5 Answers
The first line of /usr/local/bin/ipython is "#!/usr/bin/python3" I could edit that line to use python instead of python3 or it was as simple as run with:
python /usr/local/bin/ipython 2 I found it best to do:
which ipython
This shows the location of your ipython file that gets run when you type ipython. Then edit that (I used gedit: sudo gedit /usr/local/ipython, or whatever path you get from which ipython). Then change the first line to use the python version you want. E.g. if you want python3.5, change the first line to #!/usr/bin/python3.5.
Install latest version of the iPython for the Python 3 using the pip (recommend)
$ sudo pip3 install ipythonFor run the installed iPython for the Python 3 use:
$ python3 `which ipython3`or straightforward
$ ipython3 I think is a good idea to move to python3, but if you want to use python 2.7 instead, you can move using anaconda.
1Reinstall it using following command and it will unlink:
make sure you pip is also working in python2 if not do following:
sudo python -m pip install -U --force-reinstall pipOnce pip is unlinked from python3 then do following to unlink ipython from python3 as well:
sudo python -m pip install -U --force-reinstall ipython