-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Spyder can't start pylsp on pip installations #17661
Comments
Hi @arian-f thank you for the feedback! Could you reset you preferences running with the reset flag ( |
still reproduce it with a new spyder config directory (%userprofile%.spyder-py3) - that should be equivalent, right? |
Just to be sure maybe try then to run Spyder using the safe-mode flag (running with that will use a clean config directory without removing yours). For that you can run |
|
Did you install Python with admin privileges? Could you start Spyder from a cmd with admin privileges and check if the pylsp starts? |
I installed python itself as admin, but packages as unprivileged user -> packages that are not part of python itself are in However I have the feeling it would be more productive to inspect why it can't find the installed package instead of general debugging attempts. Easiest would be to somehow gain a python shell instead of the pylsp start. Could you give me a pointer on how to achieve that? This is my work laptop -> I'm going off for easter now. Might look into this specifically over the weekend, but don't be surprised if I only manage to get back on Tuesday. |
Well since seems like you are able to launch manually the pylsp you could try to use the Advanced configuration ( Since you have your interpreter and packages in different places most probably as you say is something regarding the sys.path. Checking a little bit I think Spyder handles that here: spyder/spyder/plugins/completion/providers/languageserver/client.py Lines 266 to 319 in 270f141
Maybe you can check if unindenting there the line 308 ( |
@arian-f, are you setting your PYTHONPATH manually outside Spyder? Because if you do, then that should be the cause of this problem. |
@ccordoba12 PYTHONPATH is not set. The problem might be in python, however it can be solved in spyder: It's definitely confusing that Indeed, adding The same issue might occur in unix and macos. I could try to check it on linux, but I don't have access to macos. detailsI started a python shell instead of the server via:
and indead, sys.path doesn't have the
|
Ok, thanks for investigating this further @arian-f! So, this problem would be solved if we add |
exactly, e.g. this diff makes it work: $ diff -u Python39/site-packages/spyder/plugins/completion/providers/languageserver/client.py Python310/site-packages/spyder/plugins/completion/providers/languageserver/client.py
--- Python39/site-packages/spyder/plugins/completion/providers/languageserver/client.py 2022-04-19 12:33:22.461020400 +0200
+++ Python310/site-packages/spyder/plugins/completion/providers/languageserver/client.py 2022-04-19 13:12:20.711573600 +0200
@@ -297,6 +297,7 @@
# the PyLS.
if os.name == "nt" and "USERPROFILE" in os.environ:
env.insert("USERPROFILE", os.environ["USERPROFILE"])
+ if os.name == "nt" and "APPDATA" in os.environ:
+ env.insert("APPDATA", os.environ["APPDATA"])
else:
# There's no need to define a cwd for other servers.
cwd = None |
Ok, thanks for the confirmation @arian-f! I'm going to do this only for non-Anaconda installations because packages in That's why we prefer to start the server with the minimal amount of env vars, i.e. so that it can't be broken by packages installed outside the environment in which it's present. |
Problem Description
Spyder doesn't manage to start pylsp, even though it's installed.
in
server_python_$PID.log
:C:\Program Files\Python310\pythonw.exe: No module named pylsp
(there's also a corresponding GUI message after 5 or so start attempts)
however, pylsp seems to be installed correctly in a python interpreter, I can
import pylsp
, plus when I copy'n'paste the command that should start the python language server, that works.Therefore I suspect that the PYTHONPATH is set improperly inside spyder when attempting to start pylsp, without the pylsp directory
This is an installation on windows, for that matter. Pythonpath is:
and pylsp is installed in
%APPDATA%\\Python\\Python310\\site-packages
What steps reproduce the problem?
Versions
Dependencies
The text was updated successfully, but these errors were encountered: