The Cat
The Cat

Reputation: 2475

PyCharm debug console not working

I can run the debugger and put breakpoints to active the console but it appears as if the console doesn't pick up the code I am entering.

I can just type anything but I don't get any ouput,

a=2
print(a)
sfgsmk
..g.bbcvdgdggh

Any ideas how I can get the debug console to run the code I am typing and how to get it to show output.

I am using Community Edition 2017.1.4

Upvotes: 35

Views: 31860

Answers (11)

Ramesh Shankar
Ramesh Shankar

Reputation: 11

Am using PyCharm 2023.1 (Community Edition). I had the same issue. It worked after I selected these options which clears caches under File -> Settings --> Build, Execution, Deployment -> Pythong Debugger selected these options:

  1. Attach to subprocess automatically while debugging
  2. Collect run-time types information for code insight --> clears caches
  3. Gevent compatible

Apply those changes. It worked for me. Python Debugger Options

Upvotes: 1

Wyrmwood
Wyrmwood

Reputation: 3609

I ran into this issue today, and the fix for me was to go into the Run/Debug Configuration and uncheck Execution->Emulate terminal in output console.

After unchecking that, I now get >>> when I hit a breakpoint, and it's responsive. It does precede each line with Out[1]:, Out[2]:, and I have no idea why, but at least it's working.

Upvotes: 4

swimmer
swimmer

Reputation: 3333

Faced the same issue and even tried different PyCharm versions without success.

In the end the reason for debugging console not working was that somewhere in the repo sys.out and sys.stderr were being overwritten.

Upvotes: 0

Bernhard Stadler
Bernhard Stadler

Reputation: 2383

I had the same problem with PyCharm 2020.3 (and earlier versions) under Ubuntu 20.04 with MATE. From the answers and comments it seems that there are multiple possible reasons for this behaviour.

In my case, the debugger console responded at some breakpoints (e.g. near the beginning of the program), but not for others.

What fixed the problem for me is enabling the "Gevent compatible" checkbox the File → Settings → Build, Execution and Deployment → Python Debugger (not "Debugger").

Screenshot of Settings dialog

Relevant YouTrack issue (PY-9372)

Upvotes: 10

Ra Faniry
Ra Faniry

Reputation: 1

I am using PyCharm 2019.3. What works for me was to go to Edit Run Configuration then uncheck everything under Execution.

Upvotes: 0

duylamvo
duylamvo

Reputation: 189

Do it as @karu mentioned. In pycharm ce 2020, you can add -s in additional Arguments.

  1. From menu, Run -> Edit Configurations
  2. Add -s in to single file or template pytest like the picture

Upvotes: 0

Eypros
Eypros

Reputation: 5723

I was using pyCharm 2018.1.2 for some time. The debugger was working just fine while all of a sudden it stopped working. I am mentioning this to clarify that mine was working at first. Anyway, there wasn't any change to justify this crack down.

To me, the solution that worked was the File->Invalidate caches/Restart... and then Invalidate and Restart.

Edit:

Although the above solution worked for a while it reverted to the buggy state soon after.

The final (until further notice) solution for me was to remove the old PyCharm folder in my home folder (/home/xxxx/.PyCharmCE2018.1/ in my case) and start a new project. Basically I removed every cache and configuration the PyCharm has used so a let radical solution might also work, like just removing the cache (/home/xxxx/.PyCharmCE2018.1/system/caches in my case)

Upvotes: 1

Aditya Sriram
Aditya Sriram

Reputation: 453

I'm on PyCharm 2019.2 and I had to check the Execution > Run with Python Console checkbox in the Run/Debug Configurations to resolve this issue.

Upvotes: 4

nanotek
nanotek

Reputation: 3087

Click on the button Show Python Prompt.

enter image description here

In order to have the prompt automatically appear, go to Preferences>Build, Execution, Deployment>Console> check Always show debug console

Upvotes: 27

karu
karu

Reputation: 501

Adding -s to 'Additional Arguments' in the run configuration helped me with the same issue.

Upvotes: 21

Anconia
Anconia

Reputation: 4038

This is a known issue but the workaround is to add JB_DISABLE_BUFFERING into your environment variables (no value needed for this key) of your run/debug configuration. This resolved the issue for me on Pycharm Professional Edition 2017.1.5

Upvotes: 9

Related Questions