Kur*_*eek 11 ipython python-2.7
我安装了Python 2.7和3.5.如果我使用命令行运行脚本python,它使用Python 2.7,但如果我启动iPython,它使用Python 3:
kurt@kurt-ThinkPad:~$ python -V
Python 2.7.12
kurt@kurt-ThinkPad:~$ ipython
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.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.
In [1]:
Run Code Online (Sandbox Code Playgroud)
有没有办法启动iPython以便它使用Python 2?(我正在使用Ubuntu LTS 16.04).
Har*_*nam 11
较少侵入性的解决方案(因为我的解决方案下面不需要更改任何库文件)来解决这个问题
python2.7 -m IPython notebook
Run Code Online (Sandbox Code Playgroud)
所以一般命令是
{{python-you-want-ipython-to-use}} -m IPython notebook
为什么会这样?
因为如果你看到ipython脚本(/ usr/local/bin/ipython)它本身似乎是一个python脚本而且它有shebang(#!/ usr/bin/python3),所以ipython不是一个独立的二进制文件但是它因为一些python而得到了生命.因为ipython脚本本身需要一些python来运行它,所以你使用你选择的一些python直接运行ipython模块,而不是让/ usr/local/bin/ipython为你决定它,这就是修复'python ipython使用什么'的问题.
在ipython读取错误的python版本后/usr/local/bin/ipython,我只是改变了
#!/usr/bin/python3
Run Code Online (Sandbox Code Playgroud)
在第一行到
#!/usr/bin/python
Run Code Online (Sandbox Code Playgroud)
和Python 2已成为iPython使用的默认版本:
kurt@kurt-ThinkPad:~$ ipython
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
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)
| 归档时间: |
|
| 查看次数: |
13925 次 |
| 最近记录: |