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.
Melebius
  • 11,750
J.Serra
  • 581

5 Answers5

6

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.

6

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
J.Serra
  • 581
2

Install latest version of the iPython for the Python 3 using the pip (recommend)

$ sudo pip3 install ipython

For run the installed iPython for the Python 3 use:

$ python3 `which ipython3`

or straightforward

$ ipython3
0

Reinstall it using following command and it will unlink:

  1. make sure you pip is also working in python2 if not do following:

    sudo python -m pip install -U --force-reinstall pip

  2. Once pip is unlinked from python3 then do following to unlink ipython from python3 as well:

    sudo python -m pip install -U --force-reinstall ipython

0

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.