使用 Python 代码开始 IPython
starting IPython using Python code
我在 Windows 上的 Python 2.7 shell 并且,因为没有制表符完成和 ?
文档我快疯了,我想开始一个 IPython shell 从那里。
出于各种(非常乏味的)原因,我无法直接通过 Scripts\ipython.exe
启动 IPython。我只想要将我带到 IPython 的纯 Python 代码。我搜索并找到了以下内容:
from IPython.terminal.ipapp import TerminalIPythonApp as t;
t.instance().initialize()
或
from IPython.terminal.ipapp import TerminalInteractiveShell as t;
t.instance()
...在这两种情况下,我都以某种 IPython shell 结束,但在这两种情况下,这都不是我认为的 "normal" [=34] =] session:例如缺少颜色,缺少 In
和 Out
旁边的 [1]
,并且无法使用 ?
和 ??
查看文档字符串。
有没有办法从 Python 到 "normal" 外观和行为 IPython shell,而不必从 [=40= 出来] 并直接从 .exe
启动?原则上,我认为必须有一种纯粹的 Python(因此是跨平台的,甚至不是 Windows 特定的)方法,但我正在谷歌搜索中试图找到它。
这来自 linux 中的 ipython 起始脚本。
from IPython import start_ipython
start_ipython()
通过跟随 Scripts\ipython-script.py
的领导并查看 pkg_resources.load_entry_point
returns 在各种情况下的情况,我最终得到了以下脚本,它似乎涵盖了我的所有基础:
import sys
import IPython
try:
from IPython import start_ipython as entry_point
except ImportError:
try:
from IPython.terminal.ipapp import launch_new_instance as entry_point
except ImportError:
try:
from IPython.frontend.terminal.ipapp import launch_new_instance as entry_point
except ImportError:
try:
from pkg_resources import load_entry_point
entry_point = load_entry_point( 'ipython', 'console_scripts', 'ipython' )
except ImportError:
try:
from pkg_resources import run_script
def entry_point(): run_script( 'ipython', 'ipython' ); return 0
except ImportError:
raise ImportError( 'run out of options for launching IPython version %s under Python version %s' % ( IPython.__version__, sys.version ) )
sys.exit( entry_point() )
我在 Windows 上的 Python 2.7 shell 并且,因为没有制表符完成和 ?
文档我快疯了,我想开始一个 IPython shell 从那里。
出于各种(非常乏味的)原因,我无法直接通过 Scripts\ipython.exe
启动 IPython。我只想要将我带到 IPython 的纯 Python 代码。我搜索并找到了以下内容:
from IPython.terminal.ipapp import TerminalIPythonApp as t;
t.instance().initialize()
或
from IPython.terminal.ipapp import TerminalInteractiveShell as t;
t.instance()
...在这两种情况下,我都以某种 IPython shell 结束,但在这两种情况下,这都不是我认为的 "normal" [=34] =] session:例如缺少颜色,缺少 In
和 Out
旁边的 [1]
,并且无法使用 ?
和 ??
查看文档字符串。
有没有办法从 Python 到 "normal" 外观和行为 IPython shell,而不必从 [=40= 出来] 并直接从 .exe
启动?原则上,我认为必须有一种纯粹的 Python(因此是跨平台的,甚至不是 Windows 特定的)方法,但我正在谷歌搜索中试图找到它。
这来自 linux 中的 ipython 起始脚本。
from IPython import start_ipython
start_ipython()
通过跟随 Scripts\ipython-script.py
的领导并查看 pkg_resources.load_entry_point
returns 在各种情况下的情况,我最终得到了以下脚本,它似乎涵盖了我的所有基础:
import sys
import IPython
try:
from IPython import start_ipython as entry_point
except ImportError:
try:
from IPython.terminal.ipapp import launch_new_instance as entry_point
except ImportError:
try:
from IPython.frontend.terminal.ipapp import launch_new_instance as entry_point
except ImportError:
try:
from pkg_resources import load_entry_point
entry_point = load_entry_point( 'ipython', 'console_scripts', 'ipython' )
except ImportError:
try:
from pkg_resources import run_script
def entry_point(): run_script( 'ipython', 'ipython' ); return 0
except ImportError:
raise ImportError( 'run out of options for launching IPython version %s under Python version %s' % ( IPython.__version__, sys.version ) )
sys.exit( entry_point() )