huggingface / knockknock

🚪✊Knock Knock: Get notified when your training ends with only two additional lines of code
MIT License
2.78k stars 234 forks source link

[AWS EC2] RuntimeError: No recommended backend was available #25

Closed g-karthik closed 5 years ago

g-karthik commented 5 years ago

In an AWS EC2 instance with the Deep Learning AMI installed, I first did source activate pytorch_p36 to activate that particular pre-built environment by AWS. Next, I did pip install knockknock. This was successful.

I created an appropriate Gmail account to send notifications, and then I created a script called testing_kk.py which contains the following code (removed the email addresses for privacy):

from knockknock import email_sender

@email_sender(recipient_email="<my email address>", sender_email="<sender email address>")
def train_your_nicest_model(your_nicest_parameters):
    return {'loss': 0.9} # Optional return value

if __name__ == "__main__":
    train_your_nicest_model(1)

When I run the above code in the same environment, I get the following stack-trace:

Traceback (most recent call last):
  File "testing_kk.py", line 8, in <module>
    train_your_nicest_model(1)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/knockknock/email_sender.py", line 50, in wrapper_sender
    yag_sender.send(recipient_email, 'Training has started 🎬', contents)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yagmail/sender.py", line 147, in send
    self.login()
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yagmail/sender.py", line 246, in login
    self._login(self.credentials)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yagmail/sender.py", line 203, in _login
    password = self.handle_password(self.user, password)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yagmail/sender.py", line 209, in handle_password
    return handle_password(user, password)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yagmail/password.py", line 11, in handle_password
    password = keyring.get_password("yagmail", user)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/keyring/core.py", line 55, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/keyring/backends/fail.py", line 24, in get_password
    raise RuntimeError(msg)
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.

From the README, it sounded like running this script would ask me for the sender email password upon the first run and consequently it would be stored in the system keyring service for future runs. But that didn't seem to happen above.

I tried running pip install keyring and it seems to have been installed already, so I'm unsure why it says the backend was unavailable at run-time. Any ideas?

g-karthik commented 5 years ago

Ah, looks like I need to run pip install keyrings.alt as well in addition to pip install keyring. Closing the issue!