简体   繁体   English

如何让PyCharm在现有控制台中运行当前文件?

[英]How can I make PyCharm run the current file in the existing console?

If I try to run the file that I'm currently editing, it opens a new Python console window each time. 如果我尝试运行当前正在编辑的文件,则每次都会打开一个新的Python控制台窗口。

How can I make PyCharm run the current file using the console I already have open (ie the one that opens under Tools > Python Console...)? 如何使用已经打开的控制台(即在“工具”>“ Python控制台...”下打开的控制台)使PyCharm运行当前文件?

I know there is an "Execute Selection in Console" feature, but I don't want to onerously select code. 我知道有一个“在控制台中执行选择”功能,但是我不想繁琐地选择代码。 I want to run the entire file. 我想运行整个文件。

I'm trying to emulate the F5 run functionality in Spyder. 我正在尝试在Spyder中模拟F5运行功能。

Edit: 编辑:

Spyder also has a User Module Reloader (UMR) feature that reloads user-defined modules each time a file is run in the interactive console (as opposed to manually doing imp.reload() ). Spyder还具有用户模块重新加载器(UMR)功能,该功能每次在交互式控制台中运行文件时都会重新加载用户定义的模块(与手动执行imp.reload() )。 Does PyCharm also have such a feature? PyCharm是否也具有这样的功能?

If I understand you correctly: Since PyCharm 2017.3 there is an action "Execute File in Console" which does exactly that. 如果我正确理解您的信息:从PyCharm 2017.3开始,将执行一个操作“在控制台中执行文件”,该操作正是该操作。 You can find it with Find action (Ctrl + Shift + A) and execute currently selected file. 您可以使用“查找”操作(Ctrl + Shift + A)找到它并执行当前选择的文件。

On Pycharm 2018.1.4 you have to select "Run File in Console" the first time you wish to run a file in the console. 在Pycharm 2018.1.4上,您第一次希望在控制台中运行文件时必须选择“在控制台中运行文件”。 Subsequently, you have to select the green arrowhead or press Shift+F10. 随后,您必须选择绿色箭头或按Shift + F10。 All subsequent runs after the first will be executed in the open python terminal. 第一次之后的所有后续运行将在open python终端中执行。

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

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