sublimelsp / LSP-pylsp

Convenience package for the Python Language Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use a python version installed from source

miguelangel-cc opened this issue · comments

Hi! I'm under Linux Mint 21 Vanessa (based on Ubuntu 22.04 jammy) where the python3 command points to the system python 3.10 version. In order to preserve that version for the system and use python 3.11 for development, I've installed separately python 3.11 from source. Now I have python3 and python3.11 in my PATH. Can I point LSP-pylsp to use the python3.11 command? By default it takes python3... I cannot figure out how to do it. Thank you!

I think you want to create a virtual environment and point to it. See https://github.com/sublimelsp/LSP-pylsp#virtual-environments

Ok, thank you! I've tried it but it uses python3 as far as I know... When I look for jedi with the command line find ~ -name "*jedi*" all results are into /home/<user>/.cache/sublime-text/Package Storage/LSP-pylsp/lib/python3.10/... as for example /home/<user>/.cache/sublime-text/Package Storage/LSP-pylsp/lib/python3.10/site-packages/jedi-0.18.2.dist-info. Note the python3.10 part in the paths.

Should I install python3-venv with apt as it's requested in the README file? Doing so it installs python3-venv for python3.10.

Thx!

What exactly do you want to achieve with that? Are you trying to use some 3.11 feature and it doesn't work currently? What specific feature?

I did experiment a bit and I think my suggestion wasn't entirely correct.

I believe that for the Jedi engine it might not really matter which version of Python is used by LSP-pylsp itself (the one in Package Storage/LSP-pylsp/lib/). But for various plugins that pylsp ships with (like mypy and flake8) it does matter which version is used as those won't be able to parse the document if it uses python features not supported by the version of Python used by LSP-pylsp. So it might actually be a good idea to expose a setting in this package that would allow the user to specify a path to python version that should be used by this server. Currently it uses the one that is the default one in your system (python3 on the PATH).

Adding support for that in #103

Thank you @rchl! 👍

Just found out about the configurable python_binary setting: Excellent feature, thanks for this @rchl 👍