Ipython 使用的是 python 3.5 而不是 2.7

J.S*_*rra 5 python ipython 16.04

我最近将我的系统从 15.10 更新到 16.04,但现在我遇到了 ipython 使用的解释器的问题。

现在 ipython a ipython3 使用相同的版本 (3.5.1)

我尝试重新安装 ipython,但问题仍然存在。

以下是控制台报告的版本:

$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Run Code Online (Sandbox Code Playgroud)

 

$ python3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Run Code Online (Sandbox Code Playgroud)

 

$ ipython
Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- 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.
Run Code Online (Sandbox Code Playgroud)

 

$ ipython3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- 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.
Run Code Online (Sandbox Code Playgroud)

J.S*_*rra 5

/usr/local/bin/ipython 的第一行是 "#!/usr/bin/python3" 我可以编辑该行以使用 python 而不是 python3 或者它就像运行一样简单:

python /usr/local/bin/ipython
Run Code Online (Sandbox Code Playgroud)


wor*_*ise 5

我发现最好这样做:

which ipython

这显示了在您键入时运行的 ipython 文件的位置ipython。然后编辑它(我使用了 gedit:sudo gedit /usr/local/ipython或您从 获得的任何路径which ipython)。然后更改第一行以使用您想要的python 版本。例如,如果您想要 python3.5,请将第一行更改为#!/usr/bin/python3.5.