I'm attempting to create a keypair json I can save to my directory in solana.py that I can use on a local Solana test validator. Unsure if there's any built-in functions within solana.py to do so, I attempted to do it through converting the keypair instance created to a dict, then converting that dict to a json, and then I was intending to create a file from the json.
I ran into an issue though attempting to convert the dict into a json. Below is the code attempting to do so.
from solana.keypair import Keypair
import json
#Create Keypair
created_keypair = Keypair()
#Convert Keypair object to a dict
keypair_dict = created_keypair.__dict__
assert type(keypair_dict) is dict
#Convert dict to a json
keypair_json = json.dumps(keypair_dict)
The following is the error I'm running into when converting keypair_dict into a json.
TypeError: Object of type Keypair is not JSON serializable