Skip to content

Command 'Python: Restart Language Server' resulted in an error (command 'python.analysis.restartLanguageServer' not found) #13474

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

Closed
ewerybody opened this issue Aug 17, 2020 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue

Comments

@ewerybody
Copy link

Hello, there!
I just saw the news in the release notes of 2020.8.101144: 'Add "Restart Language Server" command.' and was excited!
This way I just got the notion about a completely new background Language Server, as a dedicated replacement for Jedi? 👍

I see that note about the new language server and the possible relation but this seems like a feature above the language server itself! So yes: If I set python.languageServer to Pylance there are other issues but I can restart with this command 👍

Now if it's vscode-python that starts Jedi as a language server. That command should be able to restart it?

Environment data

  • VS Code version: 1.48.0
  • Extension version: 2020.8.101144
  • OS and version: Windows 10 Pro 2004
  • Python version: 2.7.18 / 3.8.4
  • 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

Language Server restarts

Actual behaviour

Error message:

Command 'Python: Restart Language Server' resulted in an error (command 'python.analysis.restartLanguageServer' not found)

Steps to reproduce:

  1. Set language server to Jedi
  2. in command palette call Python: Restart Language Server
@ewerybody ewerybody added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Aug 17, 2020
@karthiknadig karthiknadig self-assigned this Aug 18, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Aug 18, 2020
@karthiknadig
Copy link
Member

Looks like we have some issue with command registration. See related (but reverse issue) #13441

@karthiknadig karthiknadig added investigating We are looking into the cause of the issue and removed triage labels Sep 15, 2020
@JP01
Copy link

JP01 commented Feb 5, 2021

I'm getting this even with language server = pylance
It won't run for anything! :(
For some reason no autocomplete/gotos work anymore :(

@karthiknadig
Copy link
Member

@JP01 Try this and see if it helps. Some times it is just a bad install.
Looks like you might have a bad update. 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).

@alanwilter
Copy link

Thanks @karthiknadig, that seemed to work but, honestly, I tried VS a couple of years ago and because of issues like that I gave up and went back to Eclipse, yep.

Now I'm trying again, I was quite happy until now... Is there any method to keep the latest working launch.json and settings.json (both User and Workspace) saved for prompt recover?

@alanwilter
Copy link

This issue seems to happen to me every time I try to use JediLSP. BTW, what's difference from the usual Jedi?

@karthiknadig
Copy link
Member

@alanwilter There is a option to sync your settings. This is a good question to ask on the VS Code repository.

JediLSP is an experimental version of Language Server implemented based on the Jedi library. When you set Language Server as Jedi, we import jedi library and manually query it for the completion details, hover, etc. With JediLSP, it uses Jedi library over the Language Server Protocol, this allows us to extend jedi's capabilities easily. Right now, you get few additional things when using JediLSP, rename, refactoring, and code outline. But this is still experimental, and we are still working out the issues with it, so we have both jedi and jediLSP available to slelect.

@alanwilter
Copy link

Thanks @karthiknadig, not my intention to hijack this issue. Stackoverflow, e.g., does not know yet about JediLSP and I do believe it is the one causing the issue reported here, though I also noticed that Visual Studio IntelliCode Insiders is not playing well with Pylance.

@sloria
Copy link

sloria commented Apr 5, 2021

I am also seeing that the Python language server is failing to start (even with Pylance installed and enabled). I've tried the following:

  • Verified that I'm using the latest versions of all extensions
  • Verified that I'm on the lastest version of VS Code (1.55.0)
  • Followed the steps suggested above for re-installing the Python and Pylance extensions
  • Uninstalling VS Code, removing ~/.vscode, re-installing VS Code, then syncing settings using the Settings Sync extension.

If I try to run Python: Restart Language Server I get Command 'Python: Restart Language Server' resulted in an error (command 'python.analysis.restartLanguageServer' not found).

Please let me know if I can provide any more useful information for diagnosing this.

@sloria
Copy link

sloria commented Apr 5, 2021

Ah, after I re-created my virtualenv (I'm using pyenv+pyenv-virtualenv), restarted VS Code, then re-selected the interpreter using Python: Select Interpreter, the issue is resolved for me.

@fharper
Copy link

fharper commented Oct 19, 2021

@JP01 Try this and see if it helps. Some times it is just a bad install. Looks like you might have a bad update. 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).

Solved my problem.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 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 investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests

6 participants