23

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

1
  • I am also facing this issue in the remote development. Plugin reinstalled. Spotted 2024-01-05 10:52:01.448 [warning] Via 'product.json#extensionEnabledApiProposals' extension 'ms-python.python' wants API proposal 'registerIssueDataProvider' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned. in the Output -> Window, but no idea if that's related. Commented Jan 5, 2024 at 8:57

8 Answers 8

54

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

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

3 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
Click on the python extension via the extension window then you'll probably see restricted on the footer bar below the area of the screen that scrolls. It's towards the left side. Click it and it will give you the option to go use trusted mode
Thank you, this was the answer for me as well!
5

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!!

Comments

4

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

image

1 Comment

that did the trick, in my case the extension needed to be updated and then I had to restart VSCode
2

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?

Comments

1

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>

Comments

0

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.

Comments

0

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.

Comments

0

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.

Comments

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.