Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running code in PyCharm's console

Are there any smooth way to run Python scripts in the PyCharm's console?

My previous IDE - PyScripter - provides me with that nice little feature. As far as I know PyCharm has 2 ways of running script in console: 1) Select a bunch of code and press Ctrl+Alt+E. 2) Save the code in a file and import it from the Console.

Are the any way to do it by pressing "Run" or "Debug" buttons? I need to see the result of my script in the console and all variables available to manipulate.

like image 480
night_bat Avatar asked Feb 02 '14 20:02

night_bat


People also ask

How do I run a .PY file in PyCharm terminal?

Running python scripts using pycharm is pretty straightforward, quote from docs: To run a script with a temporary run/debug configuration Open the desired script in the editor, or select it in the Project tool window. Choose Run on the context menu, or press Ctrl+Shift+F10.

How do I run a Python file from console?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!


1 Answers

In the Run/Debug Configuration, add -i to the interpreter options. This will stop it from closing a python session even after a successful run. I.e. you will be able to see all the variable contents

like image 122
Patrick Avatar answered Oct 19 '22 04:10

Patrick