Poetry environment do not appear in Pycharm with WSL2

306 views Asked by At

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

2

There are 2 answers

0
Eskapp On BEST ANSWER

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

1
Nitkarsh Chourasia On

Ensure that you have installed Poetry in your WSL2 environment. You can do this by running the following command in your WSL2 terminal: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -.

Once you have installed Poetry, activate your Poetry environment by running poetry shell in your WSL2 terminal.

In PyCharm, click on the Python Interpreter selector and choose Add New Interpreter.

Select On WSL and wait until PyCharm detects Linux on your machine and completes introspection.

In the left-hand pane of the dialog, you should now see a list of available interpreters, including your Poetry environment.