Selecting Python version with LSP (specifically: lsp-python-ms) reddit / emacs ---------------------------------------------------------------------- Party-Speech6467 · 2022-03-30 23:16 Hello, I've been using Emacs for 8 years now. I stopped fiddling with my config maybe 3-4 years ago as I became jaded having things break all the time for no apparent reason and getting bored fixing stuff But now I am using LSP mode for the first time. I think it is amazing. I am using One problem: it assumes Python 2 for some reason. Example: when mousing over a return type annotation (underlined with red to suggest an error) it says: invalid syntax, return annotations require 3.x But I want/wish to use Python 3.10. How do i configure this? How do I make sure it's using the Python I want and the environment (i.e. the libraries) I want too? Thanks. ---------------------------------------------------------------------- yep808 · 2022-03-31 00:26 Try this: (setq python-shell-interpreter "python3") ---------------------------------------------------------------------- Party-Speech6467 · 2022-03-31 03:00 Sadly, this does not work. I thank you for your help though. ---------------------------------------------------------------------- polaris64 · 2022-03-31 07:34 Perhaps `(setq lsp-pyright-python-executable-cmd "python3")` instead? Each language server usually has various `lsp-mode` configuration options such as this, so you might need to choose the correct option for your specific server. ---------------------------------------------------------------------- astoff1 · 2022-03-31 11:20 If you activate the desired virtualenv and launch Emacs from there, them everything should work (make sure there are no extra settings like lsp-pyright-python-executable-cmd in place). If the above is true for you, the next step is to look for a way to "activate the venv" from within Emacs. There are numerous packages for this, but I recommend buffer-env or envrc.