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.
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
2 Comments
Thomas K
Typing
ipython will actually get you whichever version you installed it on most recently.ZengJuchen
In OSX I can't use ipython3 to start py3 version, how to solve that?
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.
pip3 install ipython?ipythonit will run using Python2 even if you install Python3 later. Maybe this will help.pip3 install ipythonthen simply useipythonoripython3, there is no need to do anything else