Ulises Albanés
Ulises Albanés

Reputation: 221

VSCode error: "Command Python resulted in an error (comand 'python.setInterpreter' not found)

I started using venvs on Visual Studio Code, and when I am trying to use pandas, by import pandas

it gives me this error

"Import "pandas" could not be resolved from source"

So I tried to use ctrl+shift+p to change python interpreter in vscode, I get this error

"Command Python resulted in an error (comand 'python.setInterpreter' not found).

Upvotes: 22

Views: 51904

Answers (8)

Tony C
Tony C

Reputation: 23

I had some issues with the same error - it turned out that the MS Python extension was set by default to a pre-release version (v2024.21.2024112701); I switched to the Release Version using the available button.

After this the Python file association re-established itself and my conda environments were recognised.

PS Also downgrade the python debugger to avoid being prompted for a debugger when running code with CTRL + F5.

Upvotes: 0

Dan
Dan

Reputation: 773

In my case, none of the above described solutions worked.
I updated the VS code and reloaded the window and that resolved the issue.

Current VS code version is 1.85.2.

Upvotes: 0

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83676

In my case this happened when usig Remote SSH extension and doing Python development on a remote server. The issue was caused by Datadog agent that corrupted any application on the server.

Upvotes: 0

ViNOJ
ViNOJ

Reputation: 35

I was able to fix this issue by adding below details in settings.json of vscode.

"python.venvFolders" : <Your venv folders>
"python.venvPath" : <Your Python path>

Upvotes: 1

Suchint
Suchint

Reputation: 589

For me, shifting from restricted mode to trusted window mode worked.

Just click on the restricted window on the bottom and just select "Trust" in the pop up window.

https://code.visualstudio.com/docs/editor/workspace-trust#_extensions

Upvotes: 52

Yusuf Syam
Yusuf Syam

Reputation: 781

In my case, i just reinstall the python extension from microsoft then reload the vscode.

image

Upvotes: 3

wen
wen

Reputation: 955

In my case, I solve it by clicking the "Extensions" button in the left sidebar of VSCode and "Reload" python. (which will show a blue reload button in the lower left corner of Python's block, just click it)

It works for me!!

Upvotes: 5

Thamognya
Thamognya

Reputation: 153

I suggest 2 ways to fix this, first uninstalling and reinstalling the extensions. On Linux (and MacOS I believe), deleting ~/.vscode/extensions/ and then manually reinstalling will help. If that does not work you can try manually setting the python interpreter (see: vscode documentation on manually specifying an interpreter).

For more information, I recommend you to look through How to start debugging Python 3.6 in Visual Studio Code?

Upvotes: 2

Related Questions