Search code examples
pythonvisual-studio-codepython-poetry

vscode can't find python with poetry and wsl


I want to use a python interperter "created" by poetry in vscode trough WSL, but the right python version doesn't show up in vscode.

I run the following commmands in a WSL terminal:

$ poetry shell
Spawning shell within /home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7
$ code .

the only interperters found in vscode are the ones in /usr/. I have tried manually inputting the path to the virtualenv but no luck. This is the path which python returns: /home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7/bin/python


Solution

  • You can either manually specify "python.pythonPath" to /home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7/bin/python or try setting "python.venvPath" to /home/kwint/.cache/pypoetry/virtualenvs and that should detect all virtual environments created by Poetry.

    Also, please 👍 the feature request to detect Poetry virtual environments if you would like to see official support.