简体   繁体   English

在脚本执行后启动ipython qtconsole作为交互式解释器

[英]Start ipython qtconsole as interactive interpreter after script execution

I have ipython with qtconsole installed and can start it via ipython qtconsole . 我安装了ipythonqtconsole ,可以通过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. 我还可以通过ipython -i my_script.py运行脚本, ipython -i my_script.py在脚本完成后或者抛出异常时保留在交互式解释器中。 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. 但我无法弄清楚如何组合它们:我想做ipython -i qtconsole my_script.py但无论我尝试什么,它都会抱怨无效的标志。 Any hint how to do that? 有什么提示怎么做?

Interesting, it seems that either this option was forgotten or not wanted in the qtconsole. 有趣的是,似乎这个选项在qtconsole中被遗忘或不想要。 A way around this (or perhaps an intended way?) is to use the -m flag. 绕过这个(或者可能是预期的方式?)的方法是使用-m标志。 This runs a module as a script so you if you called: 这会将模块作为脚本运行,因此如果您调用了:

ipython qtconsole -m my_script

it will run the code in my_script , for me this works. 它会在my_script运行代码,对我来说这很有用。 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. 请注意,它必须是my_script而不是my_script.py否则会抛出错误,因为它正在查找模块而不是文件。 Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM