Skip to content

command 'python.setInterpreter' not found #14959

Closed

Description

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 (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Dec 14, 2020
  2. changed the title [-](command 'python.setInterpreter' not found)[/-] [+]command 'python.setInterpreter' not found[/+] on Dec 14, 2020
  3. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 14, 2020
  4. karrtikr commented on Dec 14, 2020

    @karrtikr

    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.

  5. karthiknadig commented on Dec 15, 2020

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

  6. linminhtoo commented on Dec 15, 2020

    @linminhtoo
    Author

    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.

  7. linminhtoo commented on Dec 15, 2020

    @linminhtoo
    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

  8. karthiknadig commented on Dec 15, 2020

    @karthiknadig
    Member

    Lin Min Htoo (@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?

  9. linminhtoo commented on Dec 22, 2020

    @linminhtoo
    Author

    Lin Min Htoo (@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.

  10. karthiknadig commented on Jan 4, 2021

    @karthiknadig
    Member

    Lin Min Htoo (@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.

  11. bharel commented on Feb 7, 2021

    @bharel

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

  12. karthiknadig commented on Feb 8, 2021

    @karthiknadig
    Member

    Bar Harel (@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).
  13. 15 remaining items

  14. rchiodo commented on Feb 19, 2021

    @rchiodo

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

  15. rchiodo commented on Feb 19, 2021

    @rchiodo

    Delete the entire extension folder that is.

  16. vshargin commented on Feb 20, 2021

    @vshargin

    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.

    Karthik Nadig (@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.

  17. Lestt commented on Feb 23, 2021

    @Lestt

    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

  18. karthiknadig commented on Feb 23, 2021

    @karthiknadig
    Member

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

  19. ctphillips commented on Mar 11, 2021

    @ctphillips

    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 Lin Min Htoo (@linminhtoo) ?

  20. karthiknadig commented on Mar 11, 2021

    @karthiknadig
    Member

    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.

  21. ctphillips commented on Mar 12, 2021

    @ctphillips

    Karthik Nadig (@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?

  22. ctphillips commented on Mar 12, 2021

    @ctphillips

    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.

  23. hollyjrobertson commented on Mar 14, 2021

    @hollyjrobertson

    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!

  24. karthiknadig commented on Mar 14, 2021

    @karthiknadig
    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.

  25. ghost removed on Mar 14, 2021
  26. LuccasSousa commented on May 11, 2021

    @LuccasSousa

    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.

  27. locked as resolved and limited conversation to collaborators on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions