Reputation: 373
I have tried to build a new PyCharm project by poetry environment, while setting up it showed
and cannot setup the interpreter. Have anyone got the similar problem before and know how to solve this error?
Update
I have upgraded the PyCharm version to PyCharm Professional 2022.1.1 and the problem still remain.
Upvotes: 7
Views: 17268
Reputation: 791
The suggestion by @Natacha is helpful, but didn't complete the job for me. My own personal fails had to do with accepting Pycharm recommendations for the location of the poetry and python binaries. Be sure to get them right! In the Pycharm terminal (in my case, Gitbash):
# Location of python from pyenv
pyenv which python
# Location of poetry binary
which poetry
Paying attention to the details saves a lot of grief :)
Upvotes: 0
Reputation: 1250
This happened to me when using pyenv and having selected a local Python for that project directory different from the one used to install Poetry. So, this makes pythons local (Pyenv set for project) adn poetry selected (the one used to install) are not found by PyCharm.
Change Poetry's config (in my case global, but you can by project) to take always the active Python instead of the Poetry installed one.
poetry config --list
virtualenvs.prefer-active-python
(default is false)poetry config virtualenvs.prefer-active-python true
Check that took effect repeating step 1.
Try again on PyCharm.
Upvotes: 3
Reputation: 373
Alright, I have fixed this problem.
Below is my debug steps, hope it can help those who are struggling in the same situation:
PyCharm team
with no responcepoetry env info
and it showed that the local virtualenv
is NA
poetry env use $(which python)
, yet it returned Skipping virtualenv creation, as specified in config file
and this answer gave me a hint.poetry config --list
and it showed that virtualenvs.create = false
virtualenv
creation by the command poetry config virtualenvs.create true
PyCharm IDE
and tried to add the interpreter again and it WORKED!!I am not sure if the command poetry config virtualenvs.create true
is permant or not.
Upvotes: 11