如何退出PyCharm的‘run file in console’模式以重新运行代码?
Hey there! I’ve been stuck in this exact situation before—it’s so frustrating when you can’t re-run your code because the console’s locked into that "Run File in Console" state. Let’s fix this step by step:
Stop the active console session first
Look at the top-right corner of your console panel (like in your screenshot) and click the red square stop button (⏹️). This will terminate the current running session, and the console should jump back to a normal>>>prompt. You should be able to re-run your code right after this.If stopping doesn’t work, restart the Python Console
If the console still won’t let you re-run code, head to the top-left of the console panel where it says "Python Console". Click the dropdown menu next to it and selectRestart Python Console. This will fully reset the console environment, wiping the previous "Run File" state entirely.Pro tip for next time
Instead of using "Run File in Console", try using the regular green triangle "Run" button (▶️) for your script. This launches a dedicated run window instead of hijacking the Python console, so you won’t run into this lock-up issue again.
内容的提问来源于stack exchange,提问作者Heisenberg

