I want LSP to allow me to use pyright with peotry projects. The problem is, that the venv of a poetry project is kind of arbitrary and can change. So I can not configure it in the pyright config file.

Can LSP be configured to "autodetect" this environment and set it for pyright when I open a project?

  • "Autodetect"? I can't even configure pyright to use venv manually.
    – 3N4N
    Commented Oct 11, 2022 at 5:58
  • I am not very sure, what is LSP, maybe lightest supersymmetric particle? :-) Probably you wanted to ask it on the stackoverflow.com , but not sure. Note, your question will be likely closed also there, because probably not even they know, what is LSP. Note, technically would be easy to move your question there, but... but.... but... there are some major structural problems on this site network.
    – peterh
    Commented Mar 30 at 19:49
  • @peterh Lsp Stands for "language Server Protocol" and is used to Bring Features, Like language specific autocompletion to vim. Sorry for Not explaining it, but since the term is used in several questions Here, i assumed its a known term.
    – Nathan
    Commented Apr 1 at 7:41

1 Answer 1


Pyright correctly recognizes python on your PATH. So if you activate a virtual environment in a shell and open neovim there, everything should work as expected.

Run the following command in neovim

!which python


echo $PATH

to see whether the virtualenv python is detected in neovim.

  • !which python has nothing to do with neovim, though. It's a shell command.
    – 3N4N
    Commented Nov 2, 2022 at 7:07
  • 1
    Yes, it is a shell command but the $PATH environment variable will be propagated to the subshell command executed in neovim. So it can tell which python will be picked by pyright (it chooses one as per $PATH) -- unless you configured pyright to use a different python interpreter. Commented Nov 7, 2022 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.