5

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.

9
  • 1
    Did you install ipython3? pip3 install ipython? Commented Aug 9, 2015 at 17:53
  • If you had Python2 when you first installed ipython it will run using Python2 even if you install Python3 later. Maybe this will help. Commented Aug 9, 2015 at 17:53
  • Change system python environment path. Commented Aug 9, 2015 at 17:56
  • @SDilmac, why would you suggest doing that? Commented Aug 9, 2015 at 18:04
  • 1
    @dsaxton, pip3 install ipython then simply use ipython or ipython3, there is no need to do anything else Commented Aug 9, 2015 at 18:04

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

2 Comments

Typing ipython will actually get you whichever version you installed it on most recently.
In OSX I can't use ipython3 to start py3 version, how to solve that?
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.