poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Error Creating New Poetry Environment

Open Arthur-Huan opened this issue 2 years ago • 2 comments

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: <Ubuntu 22.04.1 LTS>
  • Poetry version: <1.2.1>
  • Link of a Gist with the contents of your pyproject.toml file: <!-- Gist Link Here -->

Issue

This is my first time using Poetry. When using PyCharm to configure a poetry interpreter, it says

Directory /home/arthur/.cache/pypoetry/virtualenvs/pyproject-bQEURbrH-py3.10/bin/python not found

When I try again to configure the interpreting using the environment that was created, it says Error Running Poetry. The command output is:

Recreating virtualenv pyproject-bQEURbrH-py3.10 in /home/arthur/.cache/pypoetry/virtualenvs/pyproject-bQEURbrH-py3.10

The virtual environment found in /home/arthur/.cache/pypoetry/virtualenvs/pyproject-bQEURbrH-py3.10 seems to be broken.

Invalid PEP 440 version: '1.1build1'

I've seen the same error from the PyCharm forums, and applied the fix

sudo apt install python3-pip pip3 install virtualenv

Which didn't change anything. I've also tried installing python3-venv too.

Arthur-Huan avatar Sep 17 '22 20:09 Arthur-Huan

could you try it from CLI? It should work fine. What you are describing seems to be a Pycharm bug, not a Poetry one.

Secrus avatar Sep 17 '22 20:09 Secrus

could you try it from CLI? It should work fine. What you are describing seems to be a Pycharm bug, not a Poetry one.

I did try creating an environment from the CLI, however the project doesn't have an interpreter, nor does it have a poetry.lock file.

Arthur-Huan avatar Sep 17 '22 21:09 Arthur-Huan

This consistently breaks because of ubuntu packaging: https://bugs.launchpad.net/ubuntu/+source/python-debian/+bug/1926870

This is shit, but it would be good if I could at least work around dist-packages having things poetry can't work with. As it stands I don't think I can solve it at all (e.g. I can't tell it to ignore those packages that don't work).

krageon avatar Oct 04 '22 12:10 krageon

I think there are two things going on here -- Pycharm is trying to create a Poetry environment in an odd way that is affected by system packages, and failing.

@krageon, I suspect that instead you are hitting https://github.com/python-poetry/poetry/discussions/6623, especially if you have virtualenvs.create false or virtualenvs.opts.system-site-packages true set. In either of those cases this is not currently considered a Poetry bug, though I do have some ideas an interested contributor could pursue to try and avoid the pitfalls I originally described in that discussion.

In any case, barring a reproduction that doesn't involve PyCharm, I'm closing this for now -- if you can reproduce this occurring with a simple poetry install in a clean environment with default options set (e.g. in a Ubuntu 22.04 container), please open a new issue to track the PyCharm-free reproduction.

neersighted avatar Oct 04 '22 14:10 neersighted

I have neither of those things set. I'll attempt to create a docker container that has this issue so you can see what goes wrong.

krageon avatar Oct 04 '22 14:10 krageon

I see it is this https://github.com/python-poetry/poetry/issues/4597#issuecomment-1233290435 this issue. The workaround there works as well.

krageon avatar Oct 04 '22 15:10 krageon

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Mar 01 '24 07:03 github-actions[bot]