7

I have been using Visual Studio Code with the Microsoft Python extension for a couple of months now. However, just today I found that the green button I had in the top right that executed my code is gone. I have tried uninstalling the Python extension and reinstalling, I have deleted and redownloaded Visual Studio Code, I have tried installing code runner. None of these have fixed the issue.

This is the image of my Visual Studio Code, which may help to solve the issue:

This is the image of my Visual Studio Code, which may help to solve the issue.

When I tried to select the Python: select interpreter I got an error in the bottom right that says,

"Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)"

Image of the plugin I have installed.

10
  • Looks like you have no interpreter selected (bottom left) and the image isn't clear what plugins are actively installed Commented Nov 7, 2020 at 3:04
  • Is there any additional images I could provide to help? Also I am unsure how to select an interpreter. Commented Nov 7, 2020 at 4:11
  • Assuming you have indeed installed the correct plugin, you can use Ctrl+Shift+P to open the command pallette, then you could type the word interpreter... Also, your file is unsaved in the image you've provided... So, do that, or check other python files you've been able to run before Commented Nov 7, 2020 at 4:22
  • When I tried to select the Python: select interpreter I got an error in the bottom right that says, "Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)" Additionally I saved that file and nothing came up, and I went to a .py file I have worked on before and it does not work there either. Commented Nov 7, 2020 at 4:26
  • Restart vscode after you installed the plugin? Can you show an image of the plugins that are installed? Commented Nov 7, 2020 at 4:28

10 Answers 10

15

So I had faced the problem and couldn't find solution until I stared at Visual Studio Code and found at the bottom left corner that it was in restricted mode. You have to run it in trust mode and it will fix the problem.

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

1 Comment

work for me in 12/18/2024 in Windows.
9

Try the following. If that does not help, create a new bug.

Do the following to remove stale versions of the extension:

  1. Uninstall the Python extension (if you have Pylance, uninstall it first) in Visual Studio Code.

2.Close all instances of Visual Studio Code or close Visual Studio Code .

  1. Go to, %USERPROFILE%/.vscode/extensions (on Windows) or ~/.vscode/extensions on Windows/Linux/Mac.

  2. Go to Run and give %USERPROFILE%/.vscode/extensions (on Windows). It will open extensions folder.

  3. Delete any folder with the name starting with ms-python.python*

  4. Start Visual Studio Code, and install the Python extension again (also Pylance if you uninstalled it in step 1).

1 Comment

Commenting a year later, I was facing the exact same issue and this method worked perfectly for me. :)
2

If the option is not coming, there is an option to run the program on the left panel in vs code which looks something like this:

Click on it to see how it looks properly

Then you need to click debug and run or whatever the option is, if that is blurred out then you've not saved the file, first save it and then again do the same options, and then it will run.

3 Comments

When clicking that I get a blue button that says "Run and Debug" when I click that button nothing happens.
can you tell me if it's deactivated, you can try saving the file again, or if it then again doesn't happen then wait for some time, if it has not executed then tell me the issue?
When I click the button nothing comes up, I can not get the code to execute. I do not get any error messages or anything. I am not sure how to tell if it is deactivated or not.
0

It may also come from the restricted mode. Please make sure you're in a trusted window.

Comments

0

I figured it out!!! The most recent update for the Microsoft Python plugin on Visual Studio Code seems to be bugged or something; I'm not sure.

However, I installed an older version and everything works now, including bringing back the green run button.

Comments

0

Yep, it's an issue with the most recent releases of Visual Studio Code. The quick fix right now is just to roll back to an older version. You can easily do this by pressing CTRL + Shift + X in Visual Studio Code to get to the extensions menu, and then clicking the Python extension, and then clicking the little arrow to the right of "uninstall". Here, you can just click "Install Another Version".

For me v2020.10.332292344 did the trick. command 'python.setInterpreter' not found #14959

Many others are facing the issue right now too. Gets stuck at "Python extension loading" then extension host crashes when telemetry.enableTelemetry is set to false #14977

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
The essential part of the answer is to roll back vscode to an older version, which is already in my answer. The links just direct users to the specifics of the pull request and whether the repo maintainers have fixed the issue or not. Hope this makes it clear
0

I am using WSL 2, and I encountered this error today. My Visual Studio Code used to work fine until my version was automatically upgraded to 1.60. When I checked my extensions, it said that my Python extension is not installed in WSL 2, so I clicked on install and the problem was solved.

Comments

0

Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)

The error happened on the newer version 3.10.6 I installed on my new system.

I uninstalled the new Python version. Then went to Microsoft store and installed the older version 3.9 directly from the store. When I tried adding the interpreter again on Visual Studio Code, it was successful.

Comments

0

Reloading or upgrading the Python extension worked for me.

Comments

-1

Kindly install the Python interpreter from the following site: https://www.python.org/downloads/

Then Visual Studio Code will ask for permission to run the interpreter. And then it’s done.

2 Comments

I downloaded Python 3.9.0 off that link and reopened VSCode but it did not ask about an interpreter. I think I am missing something.
Unclear how this would help since OP said the run button used to be there and has been using it for months

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.