After stopping at a breakpoint, Alt+Shift+E gives Name Error while F8 does not

Answered

Here's the issue I'm having: when I stop at a breakpoint with the debugger and try to execute a line of code in the console with Alt+Shift+E, I get name errors for basically every variable. When I execute the same line as part of the normal program with F8, I get no such name error. Here's a simple example:

1  def center_in_other_rect(self, outer_rect, inner_rect):
2 x = (outer_rect[0] - inner_rect[0])/2
3 y = (outer_rect[1] - inner_rect[1])/2
4 return x, y

If I put a breakpoint on line 2 and then Alt+Shift+E that line once the breakpoint is hit, I get a name error that outer_rect is not defined. But if I then execute the lines normally with F8 (or F9, or in normal run mode), everything works fine. (The code excerpt is from a larger program, I know it wouldn't run on its own as written)

Any idea what's going on here? I can share things about my configuration if that will be useful.

0
3 comments

What PyCharm and Python versions do you use?

I couldn't reproduce the issue following your steps.

0
Avatar
Permanently deleted user

Pycharm 2020.3.4 Community Edition.

Python 3.9.1, and the interpreter selected is part of an anaconda environment.

In the Run/Debug Configurations window, I have:

- PYTHONUNBUFFERED=1

- Add content roots to PYTHONPATH checked

- Add source roots to PYTHONPATH checked

- Emulate terminal in output console checked

 

From playing around with it, I just noticed now that the issue goes away if I uncheck "Emulate terminal in output console". Is this a known issue/limitation with that setting?

0

Thanks for the additional details.

It's expected behavior because when this option is enabled, there is no Python Console started with the debugger, and when you invoke Alt+Shift+E, it starts a separate Python Console that doesn't have any connection to your debugger hence the NameError.

0

Please sign in to leave a comment.