35

I am a fairly new Pycharm user switched from other IDEs recently.

One question I have is about the interactive python interpreter, which is the "window" I can type in variables to check them after I ran my script. Pyscripter has this thing called "Python interpreter" and I know Pycharm also has.

I tried "Python Console" under "Tools", but I don't think it's the same thing. So I am wondering how I can find this Python Interpreter in Pycharm? I am using Community version 3.

Blaszard
  • 30,954
  • 51
  • 153
  • 233
Nan An
  • 633
  • 3
  • 7
  • 11
  • I had the same issue, I found all of these helpful: http://stackoverflow.com/questions/19329601/interactive-shell-debugging-with-pycharm http://stackoverflow.com/questions/19207019/interacting-with-program-after-execution http://stackoverflow.com/questions/21912882/can-i-drop-into-interactive-mode-at-a-breakpoint-in-pycharm3 – MackM Sep 29 '14 at 18:42

6 Answers6

31

I'm using Pycharm community edition version 2016.1.2 I do the following to get an interactive prompt when debugging

  1. Debug a file (put a breakpoint somewhere you want to work with)
  2. In the debug window, there should be a 'Console' tab, select it
  3. On the left tool bar of the console, there is a button 2nd from bottom "Show Python Prompt". Press it
  4. You should now see an intereractive prompt you can use inside the console (allowing you to interact with the running code)

enter image description here

As mentioned in the OP, to just get an interactive python prompt outside a running script, in the main menu bar select Tools->Python Console

enter image description here

Magically this will appear:

enter image description here

Ray
  • 40,256
  • 21
  • 101
  • 138
22

You can set the PyCharm then it runs the same as PyScripter.

Run --> Edit Configurations --> Select "Show command line afterwards".

byrony
  • 351
  • 2
  • 5
  • 1
    Is it just me or is this option not there anymore (PyCharm 2020.3 Community). There is `Run with Python Console`, which might be the same thing. – Kvothe Dec 16 '20 at 18:25
8

Yes.

To launch an interactive console

    On the main menu, choose Tools | Run Python console, or Tools | Run Django console

Running Console

Joe Golton
  • 612
  • 6
  • 12
  • 9
    I think Nan An is looking for a way to interact with the variables after his script runs, similar to the behavior in IDLE. – MackM Sep 29 '14 at 18:41
6

Run->Edit Configurations->Interpreter Options-> add -i

There will be a red prompt when your run is finished.

zaxliu
  • 2,726
  • 1
  • 22
  • 26
  • 3
    At least in 4.5.4 PyCharm offers a "Show command line afterwards" option in the Rund/Debug Configurations dialog that I found much better than the -i option (arrow up for last command works) – jan-glx Oct 28 '15 at 18:43
  • 2
    Doing this gives me `No such file or directory: '-i'`. The "show command line afterwards" works, but not after an exception is raised. IDLE does that better. – Noumenon Apr 03 '16 at 23:55
0

Choose Run, Edit Configurations, check "Show command line afterwards". It doesn't work after an exception is raised, however.

Noumenon
  • 5,099
  • 4
  • 53
  • 73
0

I have PyCharm 2021.2.3 - I know that this question is 8 years old, but for anyone looking for a solution with more modern versions:

  1. Go to the toolbar and find "Run"
  2. Run -> Edit Configurations -> Configuration -> Execution
  3. Check the box that says "Run with Python Console"

That gives me an interactive console after running my code, and I can access variables produced during runtime.

Yaseen
  • 23
  • 5