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
erpdev@erpdev:~/frappe-bench-DJST$

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/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/api.py", line 58, in handle
    return frappe.handler.handle()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/handler.py", line 30, in handle
    data = execute_cmd(cmd)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/handler.py", line 70, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/__init__.py", line 1113, in call
    return fn(*args, **newargs)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/core/doctype/user/user.py", line 1120, in generate_keys
    user_details.save()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/document.py", line 323, in _save
    self._validate()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/document.py", line 500, in _validate
    self._save_passwords()
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/model/base_document.py", line 748, in _save_passwords
    set_encrypted_password(self.doctype, self.name, new_password, df.fieldname)
  File "/home/erpdev/frappe-bench-DJST/apps/frappe/frappe/utils/password.py", 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/password.py", line 158, in encrypt
    cipher_suite = Fernet(encode(get_encryption_key()))
  File "/home/erpdev/frappe-bench-DJST/env/lib/python3.8/site-packages/cryptography/fernet.py", 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 dev.erpnext.host 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.