Reputation: 1399
I am using Helix text editor and am trying to add a Python language server (link) to it.
I installed Python 3 using the .exe
from their official website. Then I executed these commands in order to install the Python language server:
C:\Users\ZIGLA> pip config set global.trusted-host "pypi.org files.pythonhosted.org pypi.python.org"
C:\Users\ZIGLA> pip install pip-system-certs
C:\Users\ZIGLA> python.exe -m pip install python-lsp-server
Setup succeeded but when I try running the pylsp
command my system can't find it. Helix editor also can't detect it when I check its health:
C:\Users\ZIGLA> hx --health
Config file: C:\Users\ZIGLA\AppData\Roaming\helix\config.toml
Language file: C:\Users\ZIGLA\AppData\Roaming\helix\languages.toml
Log file: C:\Users\ZIGLA\AppData\Local\helix\helix.log
Runtime directories: C:\Users\ZIGLA\AppData\Roaming\helix\runtime;C:\Users\ZIGLA\AppData\Roaming\helix\runtime;\\?\C:\Users\ZIGLA\AppData\Roaming\helix\runtime
Clipboard provider: clipboard-win
System clipboard provider: clipboard-win
Language LSP DAP Highlight Textobject Indent
...
python ✘ pylsp None ✓ ✓ ✓
...
First I checked where pip
installed the Python language server:
C:\Users\ZIGLA> pip list -v
Package Version Location Installer
--------------------- ------- ------------------------------------------------------------- ---------
docstring-to-markdown 0.15 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
jedi 0.19.1 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
parso 0.8.4 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
pip 24.0 C:\Program Files\Python311\Lib\site-packages pip
pip-system-certs 4.0 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
pluggy 1.4.0 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
python-lsp-jsonrpc 1.1.2 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
python-lsp-server 1.11.0 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
setuptools 65.5.0 C:\Program Files\Python311\Lib\site-packages pip
ujson 5.9.0 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
wrapt 1.16.0 C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages pip
I inspect this folder:
C:\Users\ZIGLA> ls C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages
Directory: C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 4/16/2024 8:59 PM docstring_to_markdown
d---- 4/16/2024 8:59 PM docstring_to_markdown-0.15.dist-info
d---- 4/16/2024 8:59 PM jedi
d---- 4/16/2024 8:59 PM jedi-0.19.1.dist-info
d---- 4/16/2024 8:59 PM parso
d---- 4/16/2024 8:59 PM parso-0.8.4.dist-info
d---- 4/16/2024 8:58 PM pip_system_certs
d---- 4/16/2024 8:58 PM pip_system_certs-4.0.dist-info
d---- 4/16/2024 8:59 PM pluggy
d---- 4/16/2024 8:59 PM pluggy-1.4.0.dist-info
d---- 4/16/2024 8:59 PM pylsp
d---- 4/16/2024 8:59 PM pylsp_jsonrpc
d---- 4/16/2024 8:59 PM python_lsp_jsonrpc-1.1.2.dist-info
d---- 4/16/2024 8:59 PM python_lsp_server-1.11.0.dist-info
d---- 4/16/2024 8:59 PM ujson-5.9.0.dist-info
d---- 4/16/2024 8:58 PM wrapt
d---- 4/16/2024 8:58 PM wrapt-1.16.0.dist-info
-a--- 4/16/2024 8:58 PM 115 pip_system_certs.pth
-a--- 4/16/2024 8:59 PM 70656 ujson.cp311-win_amd64.pyd
I see that Python language server was installed in the pylsp
subfolder. However when I inspect this folder I can not see any executables. It looks like this is a python module:
C:\Users\ZIGLA> ls C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages\pylsp\
Directory: C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages\pylsp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 4/16/2024 8:59 PM __pycache__
d---- 4/16/2024 8:59 PM config
d---- 4/16/2024 8:59 PM plugins
-a--- 4/16/2024 8:59 PM 762 __init__.py
-a--- 4/16/2024 8:59 PM 3807 __main__.py
-a--- 4/16/2024 8:59 PM 9866 _utils.py
-a--- 4/16/2024 8:59 PM 23 _version.py
-a--- 4/16/2024 8:59 PM 2353 hookspecs.py
-a--- 4/16/2024 8:59 PM 2050 lsp.py
-a--- 4/16/2024 8:59 PM 35177 python_lsp.py
-a--- 4/16/2024 8:59 PM 2768 text_edit.py
-a--- 4/16/2024 8:59 PM 3834 uris.py
-a--- 4/16/2024 8:59 PM 21846 workspace.py
This plugin is needed by Helix editor. This is why I tried adding this path to the PATH
enviromental variable. By opening my Powershell profile like this:
hx $PROFILE
And adding this line inside:
$ENV:PATH += ";C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages\pylsp"
I rebooted the terminal and I could see that path was appended at the end of the PATH
:
C:\Users\ZIGLA> echo $ENV:PATH
C:\Program Files\PowerShell\7;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files\Python311\Scripts\;C:\Program Files\Python311\;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Citrix\HDX\bin\;C:\Program Files\Citrix\HDX\bin\;C:\Program Files (x86)\Citrix\Workspace Environment Management Agent;C:\Program Files\PowerShell\7\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Azure Dev CLI\;C:\Program Files\PuTTY\;C:\Program Files\nodejs\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Meld\;C:\Users\ZIGLA\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\ZIGLA\AppData\Local\Programs\Python\Python312\;C:\Users\ZIGLA\AppData\Local\Programs\Python\Launcher\;C:\Users\ZIGLA\AppData\Local\Microsoft\WindowsApps;C:\Users\ZIGLA\AppData\Local\GitHubDesktop\bin;C:\Users\ZIGLA\.dotnet\tools;C:\Users\ZIGLA\AppData\Local\Programs\Git\cmd;C:\Users\ZIGLA\AppData\Local\Microsoft\WinGet\Links;;C:\Users\ZIGLA\AppData\Roaming\helix;C:\Users\ZIGLA\AppData\Roaming\omnisharp-win-x64;C:\Program Files\Meld;C:\Program Files\Windows Application Driver;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;C:\Users\ZIGLA\AppData\Local\DeviceTestCenter\Tools;C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE;C:\Users\ZIGLA\AppData\Roaming\Python\Python311\site-packages\pylsp
However, symptoms remain. Helix can not detect pylsp
when checking its health.
Upvotes: 0
Views: 401
Reputation: 1399
When I tried to uninstall the language server I found out where the pylsp.exe
is located!
C:\Users\ZIGLA> python.exe -m pip uninstall python-lsp-server
Found existing installation: python-lsp-server 1.11.0
Uninstalling python-lsp-server-1.11.0:
Would remove:
c:\users\zigla\appdata\roaming\python\python311\scripts\pylsp.exe
c:\users\zigla\appdata\roaming\python\python311\site-packages\pylsp\*
c:\users\zigla\appdata\roaming\python\python311\site-packages\python_lsp_server-1.11.0.dist-info\*
I was adding the wrong path to PATH
all along. When I added this line in my Powershell profile:
$ENV:PATH += ";C:\Users\ZIGLA\AppData\Roaming\Python\Python311\scripts"
Now everything works fine.
Upvotes: 0