Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have IPython run using Python 3 and not Python 2

I have both Python 2 and Python 3 installed, but when I run IPython using ipython from terminal it launches Python 2. How do I get IPython to run Python 3 instead? Within the IPython reference it says you just need to use the command ipython3 from the terminal but this doesn't work. This question seems to be asked elsewhere on Stackoverflow but I don't see a very clear answer.

like image 907
dsaxton Avatar asked Aug 09 '15 17:08

dsaxton


2 Answers

You need to install ipython for python3 which you can do with pip:

pip3 install ipython

Then to start an ipython2 shell just type ipython2, for ipython3 use ipython3

like image 140
Padraic Cunningham Avatar answered Sep 28 '22 23:09

Padraic Cunningham


Uninstalling then reinstalling all my ipython's worked for me:

Uninstall:

brew uninstall ipython ## had a version installed w/ brew on my machine
pip2 uninstall ipython
pip3 uninstall ipython 

Reinstall with pip2 and pip3:

pip2 install ipython 
pip3 install ipython 

Now i get that ipython2 begins version 2.7 and ipython begins version 3.6:

mustache:~ r8t$ ipython
Python 3.6.5 (default, Apr 25 2018, 14:26:36)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: exit()
mustache:~ r8t$ ipython2
Python 2.7.15 (default, May  1 2018, 16:44:37)
Type "copyright", "credits" or "license" for more information.

IPython 5.7.0 -- 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.
like image 25
travelingbones Avatar answered Sep 29 '22 00:09

travelingbones