40

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.

1

6 Answers 6

33

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

Sign up to request clarification or add additional context in comments.

Comments

22

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

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

1 Comment

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.
8

Yes.

To launch an interactive console

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

Running Console

1 Comment

I think Nan An is looking for a way to interact with the variables after his script runs, similar to the behavior in IDLE.
6

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

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

2 Comments

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)
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.
2

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.