ValueError: Fernet key must be 32 url-safe base64-encoded bytes

I just reused my standard scripts to install from scratch …

erpdev@erpdev:~/frappe-bench-DJST$ bench version
erpnext 13.0.0-beta.9
frappe 13.0.0-beta.9

When I try to create the Administrators API key, I get the following error (split into two pieces for easier reading):

Traceback (most recent call last):
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/", line 64, in application
    response = frappe.api.handle()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/", line 58, in handle
    return frappe.handler.handle()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/", line 30, in handle
    data = execute_cmd(cmd)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/", line 70, in execute_cmd
    return, **frappe.form_dict)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/", line 1113, in call
    return fn(*args, **newargs)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/core/doctype/user/", line 1120, in generate_keys
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/", line 323, in _save
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/", line 500, in _validate
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/", line 748, in _save_passwords
    set_encrypted_password(self.doctype,, new_password, df.fieldname)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/utils/", line 60, in set_encrypted_password
    ), { 'doctype': doctype, 'name': name, 'fieldname': fieldname, 'pwd': encrypt(pwd) })
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/utils/", line 158, in encrypt
    cipher_suite = Fernet(encode(get_encryption_key()))
  File "/home/erpdev/frappe-bench-DJST/env/lib/python3.8/site-packages/cryptography/", line 36, in __init__
    raise ValueError(
ValueError: Fernet key must be 32 url-safe base64-encoded bytes.

This occurs whether I use the UI to edit the Administrator profile or if I run:

bench --site execute frappe.core.doctype.user.user.generate_keys --args 'administrator';

Any suggestions of what the root cause might be, or of a work-around, would be greatly appreciated.

Seems likely to have been caused by the Wizard completing incorrectly.

This is marked Solved. Can you please share the fix?

Thank you.

There was no fix. I just reran my installation process and ensured there were no Wizard errors.