You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a way to restart the Python Language Server #3073
If the python language server crashes or gets into an unusable state, the only way to get it working again is to reload the entire editor window. This is very inconvenient.
Environment data
VS Code version: 1.28.2
Extension version (available under the Extensions sidebar): 2018.9.2
OS and version: Windows 10 version 1803
Python version (& distribution if applicable, e.g. Anaconda): N/a
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/a
Relevant/affected Python packages and their versions: N/a
Actual behavior
The only way to restart the Python Language Server is to reload the window
Expected behavior
A menu option to restart the python language server should be present, like with Typescript
Please could you let is know why this is required.
I.e. if you are having issues with the language server, please could you file an issue with the details.
I understand the need for such a feature (a quick fix to get the extension working, without reloading the window), however at the same time I'd like to ensure we resolve the root cause, else restarting LS is merely going to mask the underlying problem.
Also please do upvote 👍 the issue so we can track and prioritize this issue.
Reacted by AngelHdz, Sergey Kozin (QS), Mark Cartagena and chlorinezorine
Please could you let is know why this is required.
I.e. if you are having issues with the language server, please could you file an issue with the details.
I understand the need for such a feature (a quick fix to get the extension working, without reloading the window), however at the same time I'd like to ensure we resolve the root cause, else restarting LS is merely going to mask the underlying problem.
Also please do upvote 👍 the issue so we can track and prioritize this issue.
Thank you for replying!
When I submitted the issue to the VSCode repository, it was implied that if there was any issue, that I must be an extension's fault. But I did my debugging. For my specific issue (issues with code hinting/intelli-sense), I removed every extension I could and only left this one (so I could debug Python files). The issue remained.
The issue is, after a while of working, intelli-sense just stops auto completing things, and sometimes, it throws errors like "undefined property asdfetasd". It looks like the language server just stops working and remains with cached data.
So I decided to try other languages in my other workspaces, like Dart language, Javascript, Actionscript 3.0 with the Actionscript & MXML extension, etc.
And guess what? I had the same issues!!!!
So, it's either these language's language servers malfunctioning, or is an issue with VSCode's Intellisense!
This happens to me in every VSCode version I install.
For example, few days ago I was working with Javascript. And I had the Workspace Settings *.json file opened for editing the Theme's colors.
And suddenly, I started to have errors that there were undefined things or syntax errors in that file. So I reloaded the workspace without changing anything in the file, and the errors went away!
Sometimes, just by saving the files, the errors go away.
But the code hinting/auto-complete/intelli-sense only gets solved if I reload the workspace.
AngelHdz Sounds like you are experiencing issues with VS Code (if you have similar issues with other languages as well).
Please could you provide a link to the original issue.
AngelHdz Sounds like you are experiencing issues with VS Code (if you have similar issues with other languages as well).
Please could you provide a link to the original issue.
AngelHdz Please could you try using the Python extension using Jedi (disable the Language Server). To do so, please open your user settings and ensure the setting Python: Jedi Enabled is selected, see below:
Let me know how that goes. If you still experience the same issues, then it is related to VS Code, else its related to the Language Server and we probably should get some logs from you (we can do that later - basically enable verbose logging).
TS server is a different product, implemented in a different language and running in a different environment. There are also fundamental differences in how LS are activated and wired up. Different LS are not always comparable.
It is doable but amount of work is far from small. Restart may be a solution for mentioned above issues with git or pip installs, but if LS crashed or got stuck analyzing something, it most probably will crash or get stuck again... The underlying issue is should be fixed preferably.
My apologies, I assumed from jakebailey's earlier comment that there was a function you could call.
The underlying issue is should be fixed preferably.
In the long term yes, but in the short term if I'm at work and my python completions system goes haywire my first thought is "Oh god how can I make this start working again as quickly as possible so I can complete my ticket" not "oh that's interesting let me start debugging my IDE"
If I have to reload the window, that means I have to stare at a blank screen while all my extensions re-initialise and I lose all the terminals I had open and any programs running in them. It's really not good for maintaining flow.
Reacted by Tomas Sandven, André Sassi, Michael Morgan, Ömer Faruk Abacı, Nour Selim and Giacomo Rosin
Mikhail Arkhipov (@MikhailArkhipov) The problem I face isn't the LS crashing or getting stuck analyzing forever, but rather it suddenly has a completely invalid state (eg: it thinks a certain variable is defined at some line while it's a few lines above/below), this happens while I'm doing interactive rebases, my guess is that files change very quickly leading the LS to be very confused as the files change during its analysis.
If there was a command to restart the LS, I'd gladly run it after one of these intensive rebases. I feel like it will be easier than fixing the underlying bug because it's quite hard to reproduce.
I still think this is doable (just needs a PR, and a whole lot of testing for the notebooks side of things...), but @hassanselim0 I'd be curious if you had tried out Pylance as your LS to see if it solved any of your issues with the LS getting confused.
Jake Bailey (@jakebailey) I actually learned about PyLance just 1 day after writing my last comment and I switched to it.
So far it's faster (don't have to wait a long time to analyze), and I can keep going to definition (F12) recursively in library code seemingly indefinitely (previously at some point I'd hit an invisible wall unable to analyse library code any further). But I'll need more time to see if this rebase confusion happens or not.
Another scenario:
I need this feature when developing with ROS2 so intellisense finds libraries I source the ROS2 distribution
. /opt/ros2/<release>/setup.bash
This will modify PYTHONPATH which points to ros2 specific libraries which I want intellisense to pick up ... which is doesn't because I have to source this in each termina and vscode doesn't provide a way to do this automatically (to my knowledge).
UPDATE: A workaround is to start vscode from a terminal where ros2 has already been sourced. This STILL leaves the problem, if I develop new code which is sourced with
. install/setup.bash
in the local workspace. So I STILL need a way that IntelliSense will reconsider PYTHONPATH and rebuilds its cache.
Yep, it's been in for a good bit. PR's here only mention the issue they fix, but I don't know exactly when someone goes back to "verify" that it works.
Activity
jimklo commentedon Nov 29, 2018
This is a much needed feature.
KLDGH commentedon Dec 1, 2018
Much needed. This exists in the Jupyter version https://donjayamanne.github.io/pythonVSCodeDocs/docs/jupyter_getting-started/
angelhdzmultimedia commentedon Mar 14, 2019
Please add this command! It's crashing a lot! And I have to reload the whole workspace window!
SIGSTACKFAULT commentedon Sep 12, 2019
[bump]
angelhdzmultimedia commentedon Sep 13, 2019
[bump]
DonJayamanne commentedon Sep 13, 2019
AngelHdz Connor K (@SIGSTACKFAULT)
Please could you let is know why this is required.
I.e. if you are having issues with the language server, please could you file an issue with the details.
I understand the need for such a feature (a quick fix to get the extension working, without reloading the window), however at the same time I'd like to ensure we resolve the root cause, else restarting LS is merely going to mask the underlying problem.
Also please do upvote 👍 the issue so we can track and prioritize this issue.
angelhdzmultimedia commentedon Sep 13, 2019
Thank you for replying!
When I submitted the issue to the VSCode repository, it was implied that if there was any issue, that I must be an extension's fault. But I did my debugging. For my specific issue (issues with code hinting/intelli-sense), I removed every extension I could and only left this one (so I could debug Python files). The issue remained.
The issue is, after a while of working, intelli-sense just stops auto completing things, and sometimes, it throws errors like "undefined property asdfetasd". It looks like the language server just stops working and remains with cached data.
So I decided to try other languages in my other workspaces, like Dart language, Javascript, Actionscript 3.0 with the Actionscript & MXML extension, etc.
And guess what? I had the same issues!!!!
So, it's either these language's language servers malfunctioning, or is an issue with VSCode's Intellisense!
This happens to me in every VSCode version I install.
For example, few days ago I was working with Javascript. And I had the Workspace Settings *.json file opened for editing the Theme's colors.
And suddenly, I started to have errors that there were undefined things or syntax errors in that file. So I reloaded the workspace without changing anything in the file, and the errors went away!
Sometimes, just by saving the files, the errors go away.
But the code hinting/auto-complete/intelli-sense only gets solved if I reload the workspace.
DonJayamanne commentedon Sep 13, 2019
AngelHdz Sounds like you are experiencing issues with VS Code (if you have similar issues with other languages as well).
Please could you provide a link to the original issue.
angelhdzmultimedia commentedon Sep 13, 2019
microsoft/vscode#80289 (comment)
DonJayamanne commentedon Sep 13, 2019
AngelHdz Please could you try using the Python extension using Jedi (disable the Language Server). To do so, please open your user settings and ensure the setting

Python: Jedi Enabledis selected, see below:Let me know how that goes. If you still experience the same issues, then it is related to VS Code, else its related to the Language Server and we probably should get some logs from you (we can do that later - basically enable verbose logging).
18 remaining items
MikhailArkhipov commentedon Jun 21, 2020
TS server is a different product, implemented in a different language and running in a different environment. There are also fundamental differences in how LS are activated and wired up. Different LS are not always comparable.
It is doable but amount of work is far from small. Restart may be a solution for mentioned above issues with git or pip installs, but if LS crashed or got stuck analyzing something, it most probably will crash or get stuck again... The underlying issue is should be fixed preferably.
Lexicality commentedon Jun 23, 2020
My apologies, I assumed from jakebailey's earlier comment that there was a function you could call.
In the long term yes, but in the short term if I'm at work and my python completions system goes haywire my first thought is "Oh god how can I make this start working again as quickly as possible so I can complete my ticket" not "oh that's interesting let me start debugging my IDE"
If I have to reload the window, that means I have to stare at a blank screen while all my extensions re-initialise and I lose all the terminals I had open and any programs running in them. It's really not good for maintaining flow.
nourselim0 commentedon Jul 11, 2020
Mikhail Arkhipov (@MikhailArkhipov) The problem I face isn't the LS crashing or getting stuck analyzing forever, but rather it suddenly has a completely invalid state (eg: it thinks a certain variable is defined at some line while it's a few lines above/below), this happens while I'm doing interactive rebases, my guess is that files change very quickly leading the LS to be very confused as the files change during its analysis.
If there was a command to restart the LS, I'd gladly run it after one of these intensive rebases. I feel like it will be easier than fixing the underlying bug because it's quite hard to reproduce.
jakebailey commentedon Jul 11, 2020
I still think this is doable (just needs a PR, and a whole lot of testing for the notebooks side of things...), but @hassanselim0 I'd be curious if you had tried out Pylance as your LS to see if it solved any of your issues with the LS getting confused.
jakebailey commentedon Jul 14, 2020
Was bored watching TV last night and made #12952 that implements this (but needs a bit more testing).
nourselim0 commentedon Jul 15, 2020
Jake Bailey (@jakebailey) I actually learned about PyLance just 1 day after writing my last comment and I switched to it.
So far it's faster (don't have to wait a long time to analyze), and I can keep going to definition (F12) recursively in library code seemingly indefinitely (previously at some point I'd hit an invisible wall unable to analyse library code any further). But I'll need more time to see if this rebase confusion happens or not.
markdude247 commentedon Jul 19, 2020
I would also vote to have a feature/command to manually restart the Language Server. It seems as though the longer it is active, the slower it goes.
jakebailey commentedon Jul 20, 2020
See: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#completions-do-not-update-andor-import-is-still-being-reported-as-unresolved-after-pip-install
(Or, try Pylance, which does not suffer from the shortcomings that make the above true)
joshwapohlmann commentedon Aug 4, 2020
Another scenario:
I need this feature when developing with ROS2 so intellisense finds libraries I source the ROS2 distribution
This will modify
PYTHONPATHwhich points to ros2 specific libraries which I want intellisense to pick up ... which is doesn't because I have to source this in each termina and vscode doesn't provide a way to do this automatically (to my knowledge).UPDATE: A workaround is to start vscode from a terminal where ros2 has already been sourced. This STILL leaves the problem, if I develop new code which is sourced with
. install/setup.bashin the local workspace. So I STILL need a way that IntelliSense will reconsider
PYTHONPATHand rebuilds its cache.camsteffen commentedon Sep 17, 2020
Looks like this issue is resolved by #12952.
jakebailey commentedon Sep 17, 2020
Yep, it's been in for a good bit. PR's here only mention the issue they fix, but I don't know exactly when someone goes back to "verify" that it works.
Lexicality commentedon Sep 17, 2020
Seems to work, thanks a lot!