16

On a fresh poetry install, I get the following error trying to install anything:

(base) ➜  celeba poetry add numpy       
Failed to unlock the collection!

How can I fix this?

a06e
  • 18,594
  • 33
  • 93
  • 169
  • 1
    Seems to be something to do with "keyring"? Maybe try [this suggestion](https://github.com/python-poetry/poetry/issues/1917#issuecomment-1235998997) from python-poetry issues – Temba Nov 14 '22 at 23:20

2 Answers2

52

There is an extensive discussion and various workarounds suggested in poetry issue #1719. Probably the fastest way to make this work is to run the following before you run poetry:

export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Fabian Ritzmann
  • 1,345
  • 9
  • 20
  • 3
    This problem is a real black-eye for the reputation of poetry. It's a great tool, but the fact that the maintainers simply will not fix this after years of complaints points to some real cultural problems within their team. – Leopd Aug 09 '23 at 04:40
2

If you are remotely accessing your work environment via SSH, add this function to your .bashrc file and run it from the remote terminal:

# Linux unlock gnome keyring
function unlock-keyring ()
{
    read -rsp "Password: " pass
    export $(echo -n "$pass" | gnome-keyring-daemon --replace --unlock)
    unset pass
}

Source: https://unix.stackexchange.com/questions/602313/unlock-gnome-keyring-daemon-from-command-line

Kyle F Hartzenberg
  • 2,567
  • 3
  • 6
  • 24