RuntimeError: No recommended backend was available. (Keyring w/ Python)
Asked Answered
F

2

6

I have a program which uses Yagmail and the keyring package to safley store email credentials. When I run this script in atom.io and idle it works.

However, after I packaged it with pyinstaller it is giving me this message:

RuntimeError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.

In my program I have

import keyring

I also have gone and installed keyring.alt

Funch answered 26/6, 2019 at 19:33 Comment(2)
Which OS are you using?Cleaning
@M.R.I have Windows 10Funch
S
2

Since i cant add comments, i am adding my inputs in answer block. hope this helps.

I also had similar issue, where i used a keyring module to store passwordin my python script and packaged it using pyinstaller. My script ran perfect when i run it directly. But when i try to run the python exe , i got same error as below

"RuntimeError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details."

I googled about this error and found below link (this may not be directly related but there someone gave a workaround). I added the workaround as suggested in the link (you have get which keyring backend you are using as well) and it worked.

Link: https://github.com/jaraco/keyring/issues/359 Code to find which keyring backend you are using

from keyring import get_keyring
get_keyring()

As suggested in the above like you can add the block somewhere in your script and then exe file will run perfectly.

Seedtime answered 19/10, 2019 at 18:13 Comment(0)
C
1

Here's what I did, based on @Rena76's answer:

  1. To get the default 'method' used to store the password, I imported get_keyring from keyring and executed the said function.

    from keyring import get_keyring
    print("Keyring method: " + str(get_keyring()))
    
  2. The retrieved method was 'keyring.backends.chainer.ChainerBackend', which works fine on the script but not when exported to an .exe file. So I set 'keyring.backends.Windows.WinVaultKeyring' as my method, given that I'm using Windows.

    keyring.core.set_keyring(keyring.core.load_keyring('keyring.backends.Windows.WinVaultKeyring'))
    
  3. Finally, so that I'm able to save the credentials on Windows Vault, I'll import win32 libraries.

    import win32api, win32, win32timezone
    

Now I can successfully perform Keyring functions, such as:

   keyring.set_password(service_name='<service>', username='<username>', password='<password>')
Citral answered 4/5, 2021 at 18:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.