Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command 'python.setInterpreter' not found #14959

Closed
linminhtoo opened this issue Dec 14, 2020 · 36 comments
Closed

command 'python.setInterpreter' not found #14959

linminhtoo opened this issue Dec 14, 2020 · 36 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@linminhtoo
Copy link

linminhtoo commented Dec 14, 2020

Environment data

  • VS Code version: 1.52.0 (user setup)
  • Extension version (available under the Extensions sidebar): 2020.11.371526539
  • OS and version: Windows_NT x64 10.0.18363
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.12 Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: just Python extension: 2020.11.371526539
  • Value of the python.languageServer setting: Jedi

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

After doing CTRL+SHIFT+P, I want to select Python Interpreter

Actual behaviour

Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)
So I cannot run any python scripts within vscode

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. I just start my vscode normally like I always do but suddenly I can't see any python interpreter selected and cannot run my python scripts. So I tried to do CTRL+SHIFT+P to select it but it gave me this error. I didn't update my Python recently also, but VSCode seems to have updated recently?

Logs

How can I retrieve detailed logs?

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@linminhtoo linminhtoo added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Dec 14, 2020
@linminhtoo linminhtoo changed the title (command 'python.setInterpreter' not found) command 'python.setInterpreter' not found Dec 14, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Dec 14, 2020
@karrtikr
Copy link

It's likely that the Python extension has not been activated. Please open a python file to activate the extension, the commands should be available after that.

@karthiknadig
Copy link
Member

Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue's priority.

If you think your issue is more of a question or configuration problem rather than a bug, please ask on Stack Overflow with the visual-studio-code and python labels for help.

Thanks for your understanding and patience!

@linminhtoo
Copy link
Author

linminhtoo commented Dec 15, 2020

It's likely that the Python extension has not been activated. Please open a python file to activate the extension, the commands should be available after that.

I don't understand what you mean. I've been coding Python for months. This happened out of the blue one day when I was trying to execute .py scripts (normally there's the green arrow button on the top right as well), so I suspect the latest update caused the issue. I am trying to rollback to an older version of the extension.

@linminhtoo
Copy link
Author

Yep. I installed v2020.10.332292344 (from 1 month ago) and everything is back to normal. Seeing as the issue started happening yesterday, it's most likely something to do with the new release that came out on 14th Dec, but then someone else posted this on 7 Nov also so maybe that one already has the issue.

https://stackoverflow.com/questions/64723778/vscode-using-the-ms-python-extension-cannot-execute-code

@karthiknadig
Copy link
Member

@linminhtoo Can you check the following folder %USERPROFILE%\.vscode\extensions and see if there are multiple ms-python.python* versions? If so remove all of them.

Also can you check your settings, are you using "python.experiments.optInto": [ "All"] setting?

@linminhtoo
Copy link
Author

linminhtoo commented Dec 22, 2020

@linminhtoo Can you check the following folder %USERPROFILE%\.vscode\extensions and see if there are multiple ms-python.python* versions? If so remove all of them.

Also can you check your settings, are you using "python.experiments.optInto": [ "All"] setting?

I deleted all folders of ms-python.python* and reinstalled the latest version of the Python extension (specifically 2020.12.424452561), but the same error returns when trying to select a Python interpreter. I also tried both ["All"] and just [] for "python.experiments.optInto" but both gave me the same error when trying to select a Python interpreter.

@karthiknadig
Copy link
Member

@linminhtoo Are you by chance installing using VSIX manually? if so, can you verify you also have ms-toolsai.jupyter (https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) extension installed. it is needed for the python extension to work.

@bharel
Copy link

bharel commented Feb 7, 2021

Happens to me as well:

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

Pylance language server, Python 3.9 (Trying to set a virtual environment).

@karthiknadig
Copy link
Member

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

Do the following to remove stale versions of the extension:

  1. Uninstall Python extension (if you have pylance uninstall it first).
  2. Close all instances of VS Code.
  3. Go to, %USERPROFILE%/.vscode/extensions (on windows) or ~/.vscode/extensions on Linux/Mac.
  4. Delete any folder with the name starting with ms-python.python*
  5. Start VS Code, and install Python extension (also pylance if you uninstalled it in step 1).

@bharel
Copy link

bharel commented Feb 8, 2021

@karthiknadig I've installed VS code 4 days ago, on a fresh system. I'm not sure I have a "stale version". I did install an older extension version though and it solved the problem. @linminhtoo did that as well and it worked for him.

@galaxyfeeder
Copy link

galaxyfeeder commented Feb 10, 2021

Happens also to me.

Tried removing old version from ~/vscode/extensions, adding and removing the python.experiments.optInto setting and also downgrading to v2020.10.332292344, none of them seem to work.

Version: 1.53.0
Commit: 8490d3dde47c57ba65ec40dd192d014fd2113496
Date: 2021-02-03T16:01:04.046Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 20.3.0

Python extension version v2021.1.502429796

In my case this does not allow me to select the pipenv virtual environment, and then I don't have the dependencies for my project, which implies that autocomplete features are not working.

EDIT: Tried again with v2020.10.332292344 and it works perfectly.

@Dungeonseeker
Copy link

Dungeonseeker commented Feb 12, 2021

Same issue here. I'm running code-server, its a totally clean install onto a clean install of Ubuntu Server 20.04 so I can 100% rule out any issues with multiple versions of the extension. Python is, quite literally, the first and only extension I have ever installed. I installed it from the built in extension page and all prerequisites are installed.

Here's the info from Help > About

code-server: v3.8.1
VS Code: v1.51.1
Commit: 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
Date: 2021-02-05T22:26:25Z
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0

Edit - Fixed but I had to roll the python extension all the way back to v2020.10.332292344

@lyndonchan
Copy link

@Dungeonseeker Rolling the python extension back to v2020.10.332292344 worked for me too

@karthiknadig
Copy link
Member

If v2020.10 version works but v2020.11 and above does not work. Then it is likely that you don't have this extension: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter.

In 2020.11 we split the python into two extensions the ms-python.python extension and the jupyter extension. For now, both are needed for the python extension to work.

@lyndonchan
Copy link

I installed the jupyter extension and updated ms-python.python to v2021.2.576481509 and that's failing for me

@karthiknadig
Copy link
Member

@lyndonchan Try 2021.1 we released 2021.2 seems like it had a bug where it fails to load for some people. Were are investigating it.

@lyndonchan
Copy link

@karthiknadig same problem after trying 2021.1

@karthiknadig
Copy link
Member

@lyndonchan Can you share the dev tools logs? (Help > Toggle Developer Tools)

@lyndonchan
Copy link

lyndonchan commented Feb 19, 2021

@karthiknadig

Activating extension 'ms-toolsai.jupyter' failed: Cannot find module 'c:\Users\home.vscode\extensions\ms-toolsai.jupyter-2021.2.576440691\out\client\extension'
Require stack:

  • c:\Users\home\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js
  • c:\Users\home\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js
  • c:\Users\home\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js.

Cannot activate extension 'Python' because it depends on extension 'ms-toolsai.jupyter', which failed to activate.

@karthiknadig
Copy link
Member

@lyndonchan what is your version of VS Code? Make sure it is at least 1.52 or greater.

@lyndonchan
Copy link

@karthiknadig it's 1.53

@karthiknadig
Copy link
Member

@DonJayamanne @rchiodo Can you take a look at why ms-toolsai.jupyter might be failing to activate?

@rchiodo
Copy link

rchiodo commented Feb 19, 2021

Is ms-toolsai.jupyter fully installed? I'd check this folder to see if the mentioned file is there:

For example, I have this:
image

We have had problems in the past when the installer didn't work.

@lyndonchan
Copy link

@rchiodo I suppose it isn't fully installed. This is what I see:
image

@rchiodo
Copy link

rchiodo commented Feb 19, 2021

I'd delete that folder then and reinstall from the marketplace.

@rchiodo
Copy link

rchiodo commented Feb 19, 2021

Delete the entire extension folder that is.

@vshargin
Copy link

vshargin commented Feb 20, 2021

Are you by chance installing using VSIX manually? if so, can you verify you also have ms-toolsai.jupyter (https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) extension installed. it is needed for the python extension to work.

@karthiknadig Thank you, this was the issue for me. Can you please make it so that the extension gives some kind of error/warning that Jupyter package is missing? I've read all the logs and I couldn't find what was wrong before I googled the issue.

@Lestt
Copy link

Lestt commented Feb 23, 2021

Same problem here with code-server v3.9.0.
I have deleted all ms-toolsai.jupyter.* and ms-python.python.* from the extension folder.

I have re-installed ms-toolsai.jupyter from the marketplace, current version v2021.2.0.
I have re-installed 'ms-python.python` from the marketplace, current version v2021.2.582707922.

I have opened a python file, and run "Python: Select Interpreter". I got this error:
Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)

I have no Python value in the drop-down in the Output panel to display any logs.

About my local python versions (I don't know if it helps), i ran this in the vscode terminal tab:

[  9:35AM ] $ python3 --version
Python 3.7.3
[  9:35AM ] $ python --version 
Python 2.7.16

Solution: I have to reverted back ms-python,python to version 2020.10.332292344

@karthiknadig
Copy link
Member

@Lestt was there nothing in the dev tools Logs? (Help > Toggle Developer Tools)

@ctphillips
Copy link

Read through all the posts. I am running Mojave on a MacBook Pro. My jupyter folder had the correct extension.js file. What seems really odd to me is I was using VSCode running a Python script a few weeks ago and everything was fine. But yesterday I went to run the same script and it failed. I haven't made any changes to my Python3 installation. Debugging led me to the error the interpreter was not loading and I noticed that it wasn't showing up in the bottom left of the status bar either (as others have reported). Reverting the ms-python.python extension to 2020.10.332292344 solved the issue. Any ideas why this is happening @linminhtoo ?

@karthiknadig
Copy link
Member

karthiknadig commented Mar 11, 2021

@ctphillips Check the developer console, and python logs. Developer console can be found here Help > Toggle Developer tools. and Python logs at Output > Python panel. If the extension did not load then you won't see Python in the possible options to select in the output panel.

@ctphillips
Copy link

@karthiknadig There is nothing in the Output > Python panel if I am looking in the correct location. I assume you mean the Output that can be reached by View -> Output. I also don't see anything in View -> Problems (It simply says "No problems have been detected in the workspace"). In the Help -> Toggle Developer tools I do see some errors and warnings. Interestingly, I see errors with v2020.10.332292344 (which eventually works) and v2021.2.636928669 (which doesn't work). In both cases, after opening vscode and it begins to load a python project, I get a warning in the bottom right of the workspace:

IntelliCode Python support requires you to use the Microsoft Python Language Server (preview)

When I click on the button: Enable it and Reload Window, the v2020.10 version loads the python interpreter and the v2020.2 never does.

Looking at the error log in the Developer Tools in v2020.2 (after enabling the Microsoft Python Language Server) I see the following errors:

IntelliCode Python support requires you to use the Microsoft Python Language Server (preview). onDidChangeNotification @ notificationsAlerts.ts:40

Cannot activate extension 'Python' because it depends on extension 'ms-toolsai.jupyter', which failed to activate. _logMessageInConsole @ abstractExtensionService.ts:718

Activating extension 'ms-toolsai.jupyter' failed: Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.. _logMessageInConsole @ abstractExtensionService.ts:718

[Extension Host] (node:81920) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. v @ console.ts:137

In addition to the errors there are 5 warnings 4 of which seem to be related to the same issue

[Extension Host] stack trace: Error: Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again. at w.reject (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:16717) at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:20787 at async w.doWriteConfiguration (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:13896) v @ console.ts:137

So I am wondering why the Extension Host is not able to write to the user settings. Maybe that is the root cause, which produces the errors?

Thoughts? Next steps?

@ctphillips
Copy link

ctphillips commented Mar 12, 2021

Okay. In the end, most of these errors were due to a typo in my user settings file. :-(
It was causing the Language Server not to be loaded on start up, and also not able to update the user settings, when I clicked on the button to enable it and reload the window. Not sure why v2020.10 was able to work after the reload (even though the settings file was not written to) but the v2021.2 wasn't able to work. But the correct Python virtual environment is loading now with the v2021.2 Python extension.

There is still one warning and one error remaining the Developer Console, but I am not seeing an obvious effects of the problem.

warning:
Overwriting grammar scope name to file mapping for scope source.java. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/java/syntaxes/java.tmLanguage.json. New grammar file: file:///Users/cphillips/.vscode/extensions/redhat.java-0.76.0/syntaxes/java.tmLanguage.json

error
console.ts:137 [Extension Host] (node:89391) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

@hollyjrobertson
Copy link

Yep. I installed v2020.10.332292344 (from 1 month ago) and everything is back to normal. Seeing as the issue started happening yesterday, it's most likely something to do with the new release that came out on 14th Dec, but then someone else posted this on 7 Nov also so maybe that one already has the issue.

https://stackoverflow.com/questions/64723778/vscode-using-the-ms-python-extension-cannot-execute-code

Thank you for this version recommendation.
I downgraded from v2021.2.636928669 to v2020.10.332292344 - VS Code WORKS now!
Thank you!

@karthiknadig
Copy link
Member

If 2020.10.* works but 2020.11.* onwards doesn't then that is due to missing this extension https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter. in 2020.11.1 we split the python extension into two, one that provides core python features and another that provide data science features.

Another thing is to ensure that everything is getting loaded correctly. VS Code recently had a problem where it would fail to extract the downloaded extension packages completely. Partial install meant that files were left out, and it shows as errors like python.setInterpreter not found. Check the developer console to see if there are any errors reported (Help > toggle developer tools to see it). Usually the error will point to some file (like extension.js) as module not found. Check if that file exists, path should be in the reported error.

For anyone running into this issue, if you are done the two things I mention above (install jupyter and there are not errors in developer console indicating missing files), then please file a separate bug.

Closing this, since this particular issue should be addressed by steps described here.

@LuccasSousa
Copy link

When I had the same problem, my problem was because of the jupyter that the python extension needs, I just updated it and it worked.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests