Home > OS >  cannot obtain output in VS code
cannot obtain output in VS code

Time:11-12

i am not getting any output whenever i try to execute any basic command , in python using VS code.

enter image description here

CodePudding user response:

You seem to be trying to run python while already in python. Try opening a bash or cmd terminal and typing in python main3.py

CodePudding user response:

Your Visual Studio Terminal has Python already opened, so when you try to execute the: & "C:/python 39/python.exe" "C:/route_to_your_file.py" Is trying to execute a line of code with this, something that has a bad python syntax.

You have two options:

  1. Close python writing exit() and then run your python script with "C:/python 39/python.exe" main2.py or "C:/python 39/python.exe" main3.py

  2. Work directly with the application of python. In that case you can write your code directly on the terminal

print("hello world")

you can (but it is not recommended) import your files as packages, with:

import main2
import main3

Since you are new on python, I recommend you the first option.

CodePudding user response:

Run the code directly:

enter image description here

rather than get into python then run the code:

enter image description here

  • Related