0

I recently installed Pycharm on a fresh PC. Unfortunately something seems to be off with the installation. When I try to enter the debug console this isn't loading. E.g. for a very simple test case

def test_stable():
    1 == 1
    2 == 2 # breakpoint in this line

when I add a breakpoint in the last line, it is stopping the execution correctly, but I can't enter the console (i.e. the little wheels keep spinning):

Debug console not loading

What is wrong with my installation here? Is this a known issue?

Edit:

When clicking the "Show Python Prompt" button a console opens, but the console is not working, there is no output from it:

Console not working

As I said above I believe this is connected to the strange behavior in the Debug Console tab.

Edit 2:

As recommended by @bad_coder I changed the test to

class Test:
    def test_trivial(self):
        test = 5
        assert 1 == 1 # breakpoint on this line

I still can't use the debug console. I also just started up my old system and can now confirm that there when clicking on console I am directly getting to the console and not the situation of my first image (with the animated spinning wheels).

Axel
  • 1,415
  • 1
  • 16
  • 40
  • The wheels keep spinning because the tests are still not complete… click on "Debugger" to enter the debugger…? – deceze Oct 17 '22 at 07:22
  • Hi, thanks for your reply. But wasn't there an option to enter the console at the "state" of the breakpoint, i.e. all variables are what they are at the breakpoint? – Axel Oct 17 '22 at 07:25
  • Not sure about that, but there's an "evaluate expression" button in the debugger that essentially allows you to do that, even if the interface isn't a console. – deceze Oct 17 '22 at 07:28
  • The console button I am referring to is also inside the debug tab, and as I remember it was possible in the past to use this console for debugging. – Axel Oct 17 '22 at 07:31
  • Are you using unittests or pytest? We don't have complete information on your configuration, but you might be running into a bug where breakpoints don't work with the `1 == 1` comparison, write that same test as `assert 1 == 1` and get rid of the other comparison without the assert. (I know this sounds strange, but in some comparisons breakpoints just don't stop). Then, I think your console is working, try setting a variable and then printing it in 2 steps, like 1º `a = 2` then 2º just `a`. As deceze said having to press the icon is normal, the other symptoms might just be quirks. – bad_coder Oct 17 '22 at 11:17
  • If it still doesn't work, just to be on the safe side, make sure you have the [run configurations like this](https://stackoverflow.com/a/59391077). But the console still has its own configs at `File` `>` `Settings` `>` `Build, Execution, Deployment` `>` `Console`... A screenshot of that would help exclude more exotic causes for the "apparent" bug. It is strange that you're not getting the echo back from the console when you do `5+5` but that might be an independent config of your interpreter itself. (The console itself is working after you press the icon, otherwise you'd get an error). – bad_coder Oct 17 '22 at 11:24
  • Because there's a subtle conceptual error in your test, it's the `assert` statement that makes a test what it is, not the `==` comparison. And there might be something in the background that doesn't work as you'd expect if if the `assert` isn't present. – bad_coder Oct 17 '22 at 11:35
  • Hi @bad_coder thanks for your comment. Unfortunately this did not solve the issue. – Axel Oct 17 '22 at 11:36
  • @Axel ok, exactly what didn't work? did you try the `a = 5` then `a`? Did you try removing `==` and using `assert` instead? The screenshots of the settings and the run config would be helpful... – bad_coder Oct 17 '22 at 11:37
  • @bad_coder I made an edit to make this clearer – Axel Oct 17 '22 at 11:47
  • @Axel you didn't understand the subtlety of what I tried to convey in my 1st comment. The spinning wheels are caused by using a "Python test" run configuration instead of a "Python" run configuration. Carefully look at the **titles of the groups on the left-hand side of the screenshot of the link in my 1st comment** [the template](https://www.jetbrains.com/help/pycharm/run-debug-configuration.html#createExplicitly). That isn't *"the bug"* the only thing that isn't conventional here is the console not giving back an echo, but you haven't confirmed if that still happens now trying to echo `a`. – bad_coder Oct 17 '22 at 11:53
  • If I understand correctly you want me to run the test as a script and not as a test, right? That is not in ideal solution in my opinion and as I said in my old installation of Pycharm the console worked just fine for tests. – Axel Oct 17 '22 at 12:10
  • @Axel no that is not what I said, configure the test to be run as a test (you didn't include a screenshot of the run configurations or how you are running the tests). – bad_coder Oct 18 '22 at 11:27

2 Answers2

0

The button you're looking for is the Python-with-a-prompt button, which switches between the console and test progress.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Yes this is the console I am talking about. This one is not working in my case and I believe it is connected to the strange loading behavior in the Debug tab. – Axel Oct 17 '22 at 07:47
0

If someone stumbles across the same issue, I believe the problem here was basically just that the Pycharm version was rather old. After downloading the current version everything works fine.

Axel
  • 1,415
  • 1
  • 16
  • 40