我在Windows上使用Python 2.7 shell,因为我在没有制表符和?
文档的情况下疯了,我想从那里启动一个IPython shell。
由于各种(非常繁琐)的原因,我无法通过Scripts\ipython.exe
直接启动IPython。我只想要纯Python代码将我带到IPython。我搜索过并找到了以下内容:
from IPython.terminal.ipapp import TerminalIPythonApp as t;
t.instance().initialize()
或
from IPython.terminal.ipapp import TerminalInteractiveShell as t;
t.instance()
...在这两种情况下我都会遇到某种类型的IPython shell,但两者都不是我认为的“普通”IPython会话:例如它缺少颜色,缺少{{1} } [1]
和In
旁边,无法使用Out
和?
查看文档字符串。
有没有办法从Python中获取“普通”外观和行为的IPython shell,而不必从Python中直接从??
启动?原则上我认为必须有一个纯Python(因而是跨平台,甚至不是Windows特定的)这样做的方式,但我正在搜索它的圈子。
答案 0 :(得分:1)
这是来自linux中的ipython启动脚本。
from IPython import start_ipython
start_ipython()
答案 1 :(得分:0)
通过跟踪Scripts\ipython-script.py
的引导并查看pkg_resources.load_entry_point
在各种情况下返回的内容,我最终得到了以下脚本,这似乎涵盖了我的所有基础:
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() )