0

I can run a python script by pressing the run python file button:

enter image description here

but unable to run the same when pressing the F5 key or run from the dropdown menu.

enter image description here

I can also run in the interactive window fine: enter image description here

And likewise i can run a notebook fine.

other checks:

I can verify that it doesn't debug by adding a breakpoint and running.

Would there be a key-binding that is missing perhaps ? What is causing this and how can one fix the issue please ?

D.L
  • 4,339
  • 5
  • 22
  • 45
  • What happens when you hit F5? My VSCode brings up a menu to let me choose an interpreter to use, then after I select it it runs the program in debug mode. Are you sure the F5 shortcut is configured in your VSCode? – crock Jul 08 '22 at 17:35
  • it looks like it is running (somewhere), but there is no output in the terminal or debug console. I dont get any option to select an interpreter. – D.L Jul 08 '22 at 17:38
  • what do you mean it looks like it is running somewhere? is it just running in debug mode? where do you see it running? you probably don't get an option to select an interpreter because it is already configured for your current project. – crock Jul 08 '22 at 17:39
  • when code is executed i see the stop / step-over / step-into / play box appear for a second, but then it goes... i can confirm that it does not execute the code (i checked this with `time.sleep(20)`. – D.L Jul 08 '22 at 17:43
  • could be a problem with your interpreter, do `ctrl` + `shift` + `p` and type `Python: Select Interpreter` and ensure it's set to the correct path – crock Jul 08 '22 at 17:48
  • also, try the suggestions in this thread: https://stackoverflow.com/questions/49529153/visual-studio-code-is-not-showing-the-ouput-of-python – crock Jul 08 '22 at 17:51
  • Yes, if i do `ctrl` + `shift` + `p` and select `run python file in terminal`, this works... it is nearly like the `f5` button is, for some reason not working. – D.L Jul 08 '22 at 17:55
  • Yeah, I don't really know what to tell you, you can try asking on the their GitHub vscode-discussion section: https://github.com/microsoft/vscode-discussions/discussions – crock Jul 08 '22 at 17:58
  • if you do `keyboard shortcuts` and search for `run` do you see anything linked to `f5` ? – D.L Jul 08 '22 at 18:03
  • Yes. F5 is bound to `Debug: Start Debugging` – crock Jul 08 '22 at 18:06
  • same, in the `when` column it says `debuggersAvailable && debugState == 'inactive'` ... do you see that also ? – D.L Jul 08 '22 at 18:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/246284/discussion-between-crock-and-d-l). – crock Jul 08 '22 at 18:12
  • I want to know which operation mode you choose from the run drop-down menu? Are all the image examples mentioned in the debug mode? Is there an error or no response – MingJie-MSFT Jul 11 '22 at 01:25

1 Answers1

0

It turns out that the error is a bug in the Python extension.

If you go to the Extensions tab, select the Python extension, then click on the little arrow next to Uninstall > Install Another Version... and install 2021.12.1559732655 the debugger should work again.

Here is the link to the fix: https://learn.microsoft.com/en-us/answers/questions/724858/vscode-debugger-not-working-for-python.html

In the meantime disable automatic updates to make it stick until they fix that.

To do this going to settings, typing python.terminal.activateEnvironment into the search bar and deactivating the checkbox.

D.L
  • 4,339
  • 5
  • 22
  • 45