skip to Main Content

I used a simple code for python in my VS Studio. Print ("Welcome") when I run it through the run button it works fine but when I want to run it through typing the file name ( eg .2_hello.py) and press enter it doesn’t run and instead leave a blank line. I don’t know what’s wrong.please help

I want the python code to run through typing the file name in terminal window of vs studio just as it works fine when I use the run button to run code. enter image description here

3

Answers


  1. You need to specific the python interpreter to run your code
    try:

    python ./02_hello.py
    
    Login or Signup to reply.
  2. Because you aren’t telling the terminal what that python file should do. In default it opens the file in vscode. Try this:

    python 02_welcome.py
    
    Login or Signup to reply.
  3. check if you have a file of that name on path.
    also type :
    python .2_welcome.py

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search