Anybody successfully using Doom + LSP + Poetry?

What happened?

Hi! I’m trying to set up Doom Emacs as a Python IDE and I’m struggling to make it work with Poetry virtual envs. Pylint says it’s unable to import my dependencies (e.g. import pandas is marked as an error), and I don’t get autocomplete for them.

So I have python (+lsp +poetry +pyenv) in my init.el (this is the stack I need), and these seem to be installed and running. I managed to install and configure (more or less) pylint and flake8. Poetry plugin is available, M-x poetry-show does list my dependencies correctly, and M-x poetry-venv-toggle does display my env name in the modeline. But pylint still doesn’t see the packages I’m importing.

I also tried enabling poetry-tracking-mode, but this seems to freeze Emacs entirely (“Poetry finished” is blinking in the modeline, and I have to kill Emacs because it stops responding).

I’m not particularly attached to lsp/pylint, if that makes any difference, I just want some linting and autocompletion that will work with Poetry.

I’m rather new to Emacs and I’m a bit lost with all these modes and plugins.

What did you expect to happen?

I want my Emacs to detect/lint/autocomplete my imports correctly based on the Poetry virtual environment.

System information

Loading data dump...

I use Doom, lsp and poetry. I have to run poetry config true then poetry install again. Tell me if that doesn’t solve it, and I’ll look through my config properly.

Thanks a lot for the reply! Uff yes, I managed to make it work using your solution. One extra thing I needed to do was to remove the venv that was already installed in the global poetry cache dir (after running the config command and before running the install command - otherwise the install command would not install it locally, even though the config was changed, because it saw the venv was already installed somewhere else).

It’s not perfect to have all these venvs scattered like this, but the emacs experience is much better now, so I guess that’s a success. Thanks again. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.