1

I recently installed Python and VS code on my new laptop, and I tried running a Python script. When I run it by pressing ctrl+alt+n, it's showing the output window like this: enter image description here

Now when I press up arrow() two times, then it's showing the output: enter image description here

What I want: when I run the code, it should be run in a single time, I don't have to press the arrow key.

1
  • Your working directory and where your file is not same! Try to change your working directory to where your python file is and then just do python Trello.py Commented Jul 10, 2021 at 4:56

3 Answers 3

1

step 1 : Install the extension called Python.

Step 2 : After installing extension python you will get the small triangle in the top right of every python file. Click it to run the program. In my case the triangle is green. enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

Sorry, but it's a little weird because I have no shortcut of ctrl+alt+n.

It looks like you modify the shortcut, but you should add the shortcut on the Python: Run Python File in Terminal command.

And you can just take F5 to run the code.

Comments

0

Change your working directory to Desktop by doing cd Desktop and just doing python <file name> will start working.

Don't forget to mark this as accepted answer if it helped you to solve your problem!

5 Comments

I run the same code on my old computer, although the files are in different locations means my python file is in a different location and the working directory is different, but it's working properly on my old computer.
I don't need to change the directory or set any path.
If you are giving exact path to run then it works, like /path/to/file but you are tying to run multiple file then changing directory to your file directory and not giving exact path would be easy. I think, In other computer you are giving exact path so it is working without changing working directory to files' directory.
No, I didn't give the exact path
As of I know, either have to have your file in working directory or you have to give exact path to run python file! I don't know how your file is working fine without having file in working directory or with exact path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.