让IPython使用Python 3而不是Python 2运行

时间:2015-08-09 17:48:24

标签: python python-3.x ipython

我安装了Python 2和Python 3,但是当我从终端使用ipython运行IPython时,它会启动Python 2.如何让IPython运行Python 3?在IPython引用中,它表示您只需要使用终端中的命令ipython3,但这不起作用。这个问题似乎在Stackoverflow的其他地方有问题,但我没有看到一个非常明确的答案。

2 个答案:

答案 0 :(得分:3)

你需要为python3安装ipython,你可以使用pip:

pip3 install ipython

然后开始ipython2 shell只需输入ipython2ipython3使用ipython3

答案 1 :(得分:1)

卸载然后重新安装我为我工作的所有ipython:

卸载:

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

使用pip2和pip3重新安装:

pip2 install ipython 
pip3 install ipython 

现在我知道ipython2开始版本2.7而ipython开始版本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.