在脚本执行后启动ipython qtconsole作为交互式解释器 [英] Start ipython qtconsole as interactive interpreter after script execution

查看:113
本文介绍了在脚本执行后启动ipython qtconsole作为交互式解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 ipython 并安装了 qtconsole ,可以通过 ipython qtconsole启动它。我还可以通过 ipython -i my_script.py 运行脚本,以便在脚本完成后或者抛出异常时保留在交互式解释器中。但我无法弄清楚如何组合它们:我想做 ipython -i qtconsole my_script.py 但是无论我尝试什么,它都会抱怨无效的标志。任何提示怎么做?

I have ipython with qtconsole installed and can start it via ipython qtconsole. I can also run a script via ipython -i my_script.py to stay in the interactive interpreter after the script finishes or if an exception is thrown. But I could not figure out how to combine them: I would like to do ipython -i qtconsole my_script.py but whatever I try, it complains about invalid flags. Any hint how to do that?

推荐答案

有趣的是,似乎这个选项在qtconsole中被遗忘或不想要。绕过这个(或者可能是预期的方式?)的方法是使用 -m 标志。这会将模块作为脚本运行,所以如果你调用了它:

Interesting, it seems that either this option was forgotten or not wanted in the qtconsole. A way around this (or perhaps an intended way?) is to use the -m flag. This runs a module as a script so you if you called:

ipython qtconsole -m my_script

它将运行 my_script 中的代码,对我来说这是有效的。请注意,它必须是 my_script 而不是 my_script.py 否则会抛出错误,因为它正在寻找模块而不是文件。希望有所帮助。

it will run the code in my_script, for me this works. Notice it needs to be my_script not my_script.py otherwise it will throw an error since it's looking for the module not the file. Hope that helps.

这篇关于在脚本执行后启动ipython qtconsole作为交互式解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆