1

I am trying run a script in VSCode. I press Ctrl + Alt + N and get this output:

[Running] python -u "the_directory_of_file\the_file_I_use.py"

[Done] exited with code=0 in 0.191 seconds

I don't see my program's output. However, when I run the script from the terminal, it works correctly. How do I get VSCode to display my program's output?

Anonymous
  • 738
  • 4
  • 14
  • 36
doctorasgr
  • 11
  • 1
  • 1
    I don't see Ctrl+Alt+N in the [list of standard keyboard shortcuts](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf). Is there an extension that you're using for Python? – David Culbreth Aug 19 '21 at 14:57
  • Yes, I use the extension Code Runner. But even without the extension, by clicking the run button (triangle), I'm getting the same results. – doctorasgr Aug 19 '21 at 15:04
  • What does your runner configuration look like in `.vscode/launch.json`? Please update your question with that info, not in the comments. – David Culbreth Aug 19 '21 at 15:05
  • Press Ctrl + Shift + ` Keys on VSCode after finish coding. And run code with the instruction, ex : `python filename.py`. – lionking-123 Aug 19 '21 at 15:06
  • I'm struggling here, because when I launch the Python Run/Debug, it launches it in the terminal. So I'm not able to re-create your issue – David Culbreth Aug 19 '21 at 15:09
  • After looking at the extension [Code Runner](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) it appears to be at least consistent with the output OP is seeing. @doctorasgr, it appears that this extension has [quite a few bugs](https://github.com/formulahendry/vscode-code-runner/issues?q=is%3Aissue+is%3Aopen+python). maybe you should report this – David Culbreth Aug 19 '21 at 15:13
  • @lionking-123 the combination doesn't work for me. It goes to terminal but it doesn't run the code. It only shows the destination of the file in the terminal. – doctorasgr Aug 19 '21 at 15:14
  • Did you run the instruction on terminal? ex : `python filename.py` or `python3 filename.py`. In here, filename must be replaced with your python file name. – lionking-123 Aug 19 '21 at 15:17
  • @DavidCulbreth I disabled the extension but still no output. – doctorasgr Aug 19 '21 at 15:19
  • @lionking-123 yes, if I copy-paste the code in the terminal it runs okay. But I want something similar to what I was doing in RStudio where I could see the results of my code straight away. – doctorasgr Aug 19 '21 at 15:20
  • @doctorasgr, the output that shows `[Running]` and `[Done]` is output from the Code Runner extension. if it's disabled, then Run and Debug should output to the Terminal, not to an extension output. maybe try re-loading the window after disabling? – David Culbreth Aug 19 '21 at 15:26
  • Can you share your code and settings? – Molly Wang-MSFT Aug 20 '21 at 02:29

1 Answers1

0

I think you should have to install python https://www.python.org/downloads/.

After installing .exe file of python. Go to downloads where you have downloaded the .exe file, open it by double click on it.

enter image description here

it looks like above window. before click on INSTALL NOW click on Add python 3.9.6 to PATH.then install it.

Now, go to VS code and try your program.

AVI RAJ
  • 55
  • 1
  • 11