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,121
  • 8
  • 50
  • 77
J.Serra
  • 571
  • 1
  • 7
  • 25
  • 1
    How did you install IPyton? What's the output of `type -a ipython` and `type -a ipython3`? – David Foerster Feb 16 '17 at 10:18
  • I installed them both with apt. $type -a ipython ipython is /usr/local/bin/ipython ipython is /usr/bin/ipython $ type -a ipython3 ipython3 is /usr/local/bin/ipython3 ipython3 is /usr/bin/ipython3 – J.Serra Feb 18 '17 at 16:34
  • 1
    `ipython is /usr/local/bin/ipython` – presumably you have a different IPython in `/usr/local/bin` in addition to the one `/usr/bin`. The latter was likely installed by the package manager. What's the output of `/usr/bin/ipython <&- | head -n 1` and `/usr/bin/ipython3 <&- | head -n 1`? – David Foerster Feb 18 '17 at 23:39
  • Images?... If you are talking about the format of my question it was edited, you can can check history. – J.Serra Feb 19 '17 at 19:33
  • There are different installed files for ipython but they are the same version. Here is the output: https://paste.ubuntu.com/24029040/ I have already solved the problem editing the first line of /usr/local/bin/ipython to "#!/usr/bin/python3 – J.Serra Feb 19 '17 at 19:37

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.

wordsforthewise
  • 808
  • 10
  • 15
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
  • 571
  • 1
  • 7
  • 25
  • 1
    When I tried, that, I got: `ImportError: No module named IPython`. – Camille Goudeseune Sep 20 '17 at 18:24
  • Have you installed the package ipython?... or may be could be an installation issue. With some packages I get problems with pip, normally if the package is on the Ubuntu repository I prefer to install them from there. `sudo apt install ipython` – J.Serra Sep 27 '17 at 22:11
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
PADYMKO
  • 433
  • 4
  • 7
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

Dwijay Bane
  • 171
  • 1
  • 5
  • 1
    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. – An0n Feb 26 '18 at 16:15
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.

  • I'm agree is better to use python3, but I'm trying to learn something about bazaar plugins and it uses python2... Until 15.10 I could use the two different interpreters with ipython and ipython3. – J.Serra May 03 '16 at 09:39