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

Have IPython run using Python 3 and not Python 2

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

您需要为 python3 安装 ipython,您可以使用 pip 完成:

pip3 install ipython

然后开始 ipython2 shell 只需键入 ipython2,对于 ipython3 使用 ipython3

卸载然后重新安装所有 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.