Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: Using the Microsoft Python extension cannot execute code

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.

like image 834
Xander Borgeson Avatar asked Jul 11 '26 10:07

Xander Borgeson


2 Answers

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.

like image 161
Mayur Kedare Avatar answered Jul 13 '26 15:07

Mayur Kedare


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).

like image 34
shaila Avatar answered Jul 13 '26 15:07

shaila



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!