0

EDIT: I tested a few more things. It looks like this error only occurs with my company's internal python executable, not /bin/python or an anaconda install. Would like to vote to close this.

If I break into the VS code python debugger (this is debugpy v1.6.6) and in the debug console run:

x = 1
[test for test in range(10) if x]

On the second line I get

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <listcomp>
NameError: name 'x' is not defined

Any ideas why this might be happening? Possibly related posts:

The first link suggests the issue was resolved in ~2018, however I am experiencing it today on my work machine with version 2023.2 of the VS code python extension. Any ideas?

Info:

  • VS code version: 1.79.2
  • debugpy version: 1.6.6
  • python: 3.8

Screenshot:

enter image description here

extremeaxe5
  • 723
  • 3
  • 13
  • I am not able to replicate. Perhaps a gif showing exactly what you're doing in the interactive debugger might help? – webelo Jul 11 '23 at 20:50
  • 1
    It seems like you are running that line only. Line 2 of your code is line 1 in the traceback. – Klaus D. Jul 11 '23 at 21:02
  • Added a screenshot – extremeaxe5 Jul 11 '23 at 21:16
  • I switched the version of vscode and python extension to be the same as yours, [and there was no problem, and it can be executed normally](https://imgur.com/q5oyEq9.png). You can try to upgrade the versions of vscoe and python extensions. The latest versions are [vscode 1.80](https://code.visualstudio.com/updates/v1_80) and [Python 2023.12.0](https://marketplace.visualstudio.com/items?itemName=ms-python.python). – JialeDu Jul 12 '23 at 06:41
  • Edited my post. – extremeaxe5 Jul 12 '23 at 18:39
  • If you find the solution, Please consider answering it and accepting it as an answer to change its status to Answered. It will also help others to solve a similar issue. See [can I answer my own question..](https://stackoverflow.com/help/self-answer), Just a reminder :) – JialeDu Jul 13 '23 at 05:40
  • May I know what's going on with the problem? If it has been solved, can you change the status of the answer to help more people with similar problems. – JialeDu Jul 31 '23 at 02:11
  • There is no answer. See my edit. – extremeaxe5 Aug 02 '23 at 22:19

0 Answers0