skip to Main Content

I have installed VS Code version 1.71.2. I have installed extension Python and Code Runner. Python programs are getting executed thru command prompt.

Commend prompt python

I opened above folder in VS code and executed manually program in terminal and it is ok.
Manual execution in terminal py program.py

However my other friend is using code runner in VS code and python programs are getting executed at his end flawlessly. In my pc it is showing error. Also he get many option on right click. like below

Context Menu option in VS code

In my case right click doesn’t show option like "Run Python File in Terminal" or " Run selection/line in python terminal". Also python file doesn’t get executed using run button. It shows error. I have added coderunner and python extensions.

Context Menu options missing and error in python code

So my questions is :

  1. How to run python file in VS code using run button like code Runner.
  2. How can I get context menu many options on right click like my friend.

I have tried Coderunner and python extensions. I don’t know what needs to be done in settings.json file.
I am expecting python execution in VS code and getting list of options in context menu on right click.

2

Answers


  1. Chosen as BEST ANSWER

    I am getting context menu option on right click after changing language mode in bottom right workspace to python.

    After that I was getting error while running using play button. [Running] python -u "d:StudyPythonhello.py" Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

    I managed this by turning off python app aliases. Disable python app alias

    Now program is running smoothly. Thank you community. palindrome program output


  2. Notice that the tab icon is not two snake heads, representing a Python script, but rather a Windows icon, what it thinks is a shell script…

    Also, your terminal is showing cmd /c, not python executing the script.

    Make sure you have Python selected in the bottom right. Or change the file associations.

    enter image description here

    Or, you can create a .ipynb notebook file instead.

    Also, 1.77 is the latest VSCode, so recommend you upgrade.

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