LSP Python Starting

Plugins for SynWrite and CudaText...
Post Reply
Michael Collier
Posts: 11
Joined: 01.04.2025 14:17

LSP Python Starting

Post by Michael Collier »

Testing LSP Pyton (debian) I get error message in console..

"NOTE: LSP: Python - Failed to create process, command: ['pylsp']; Error: [Errno 2] No such file or directory: 'pylsp'"

I installed (used pipx rather than pip, does it matter?)
pipx install python-lsp-server
pipx ensurepath
pylsp --help

also..
whereis pylsp
pylsp: /home/user1/.local/bin/pylsp

In cudatext Terminal PLus window I can invoke pylsp --help

I've reboted the machine, but still no luck, any ideas?

Thanks,
Mike
main Alexey
Posts: 2428
Joined: 25.08.2021 18:15

Re: LSP Python Starting

Post by main Alexey »

This is Linux this time, ok.
What does the command show in OS terminal:

Code: Select all

which pylsp
It finds 'pylsp'?
main Alexey
Posts: 2428
Joined: 25.08.2021 18:15

Re: LSP Python Starting

Post by main Alexey »

And: did you try to write the FULL path of pylsp to the settings/lsp_py.json ?
Michael Collier
Posts: 11
Joined: 01.04.2025 14:17

Re: LSP Python Starting

Post by Michael Collier »

which pylsp
It gives the path to
/home/user1/.local/bin/pylsp
I added the full path to lsp_py.json and now it works, thanks
main Alexey
Posts: 2428
Joined: 25.08.2021 18:15

Re: LSP Python Starting

Post by main Alexey »

Config lsp_py.json allows many options. one of them is 'env_paths' - list of paths. I hope you did not change it.

Code: Select all

 # language.py
        self._server_cmd = cfg.get(CMD_OS_KEY)
        self._tcp_port = cfg.get('tcp_port') # None => use Popen
        self._work_dir = cfg.get('work_dir')
        # paths to add to env  -- {var_name: list[paths]}
        self._env_paths = cfg.get('env_paths')
        self._log_stderr = bool(cfg.get('log_stderr'))
        self._format_on_save = bool(cfg.get('format_on_save'))
        self._disabled_contexts_for_server = cfg.get('disabled_contexts')
Michael Collier
Posts: 11
Joined: 01.04.2025 14:17

Re: LSP Python Starting

Post by Michael Collier »

The only thing I changed was lsp_py.json

Code: Select all

{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pylsp.exe"],
  "cmd_macos": ["pylsp"],
  "cmd_unix": ["/home/user1/.local/bin/pylsp"]
}
The only other change was done by pipx during install (pipx ensurepath)
at end of .bashrc

Code: Select all

# Created by `pipx` on 2025-04-03 11:36:07
export PATH="$PATH:/home/user1/.local/bin"
Michael Collier
Posts: 11
Joined: 01.04.2025 14:17

Re: LSP Python Starting

Post by Michael Collier »

From cudatext console

Code: Select all

print(os.environ.get('PATH'))
gives

Code: Select all

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
From debian terminal window

Code: Select all

echo $PATH
gives

Code: Select all

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user1/.local/bin
...not sure if it is important, but debian terminal has the extra path that is needed.
main Alexey
Posts: 2428
Joined: 25.08.2021 18:15

Re: LSP Python Starting

Post by main Alexey »

so if you run Cud from the same terminal window (with full PATH) , it still sees 'old' PATH.
so environment is not inherited.
weird.
Michael Collier
Posts: 11
Joined: 01.04.2025 14:17

Re: LSP Python Starting

Post by Michael Collier »

If I open Cudatext from terminal command line then I do get the extra path I need..

Code: Select all

print(os.environ.get('PATH'))
gives

Code: Select all

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user1/.local/bin
In my earlier post I was starting cudatext via Desktop shortcut.

BTW, I had similar issues with freepascal and trying to open files using TProcess
https://forum.lazarus.freepascal.org/in ... 547.0.html
main Alexey
Posts: 2428
Joined: 25.08.2021 18:15

Re: LSP Python Starting

Post by main Alexey »

it means that clicking Desktop shortcut, does not inherit all PATH contents to child process. it's not Cud nor Freepascal issue, i guess.
Post Reply