Search code examples
pythonpycharmubuntu-20.04windows-subsystem-for-linuxpython-poetry

Poetry environment do not appear in Pycharm with WSL2


I'm using PyCharm Pro 2022.3.1 on Windows 11, with Python running on WSL2 (Ubuntu 20.04). The Poetry environment do not appear in the Python interpreter configuration on PyCharm with WSL.

Im doing theses following steps:

  • Click the Python Interpreter selector and choose Add New Interpreter
  • Select On WSL
  • Wait until PyCharm detects Linux on my machine and completes introspection and press next
  • In the left-hand pane of the dialog, poetry environment do not appear

poetry do not appear


Solution

  • Indeed, in my experience, it does not appear. However, you can choose virtualenv and then choose to search for an existing poetry environment (this assumes that you ran poetry install to create the environment in WSL first).

    After you select virtualenv on the left hand-side, browse to the python interpreter location (click on the 3 dots) which should be something like home/<user-unix>/.cache/pypoetry/virtualenvs/<env_name>/bin/python. This path is also given when the environment is created.

    The <env_name> that I mention above is the name that is generated when you create the environment on WSL. By default it's the project name followed by a uuid.

    If you need more detailed steps, let me know. This has been working great for all my projects in the past 6 months.

    Note: WSL refers to WSL2 in my answer