假设我有以下文件
请注意,只有在使用
是否有一种方法可以在脚本内部启动 IPython 内核,以便即使我将其作为
t.py
:from IPython import get_ipython
if __name__ == '__main__':
ip = get_ipython()
if ip is not None:
print('Found IPython')
这是在Python
与IPython
中运行该程序的结果:
% python t.py
% ipython t.py
Found IPython
请注意,只有在使用
ipython
运行时,get_ipython()
才不是 None。是否有一种方法可以在脚本内部启动 IPython 内核,以便即使我将其作为
python t.py
运行,那么 get_ipython()
也不会是 None?
IPython.start_kernel()
吗? - shx2IPython.kernel
软件包已被弃用。”注意:当使用ipython kernel
入口点时,Ctrl-C将不起作用。要退出,必须通过向客户端发送“quit”或在类UNIX环境中使用Ctrl-\ 显式退出此过程。要了解更多信息,请参见https://github.com/ipython/ipython/issues/2049 要连接另一个客户端到此内核,请使用: --existing kernel-15293.json - ignoring_gravity