"'Image' is not JSON serializable", problem may have to do with cookies?

TLDR: How do you delete cookies?

I use python to manage my Docker images and containers. This has worked fine for months, but suddenly this command:

image = client.images.build(path=args.program_folder, nocache=args.force_docker_recompilation)
client.containers.run(image=image, volumes=folder_mapping)

raises an exception:

TypeError: Object of type 'Image' is not JSON serializable

I have investigated and found this page, which seems to be talking about a similar issue:

The solution says:

Got it. You've got to clear your cookies. Most likely you were running python2 and now running python3, but the cookies are still set to python2.

Which sounds like it could help me, because I did in fact switch python versions recently.

Unfortunately it doesn’t actually explain HOW to clear cookies, or even which cookies they are talking about. I am not setting any cookies myself. Do I need to run a python command? A Docker command? Who’s cookies are the problems, and how do I get rid of them?

The method build returns two items. To run, only need the image. Try image=image[0] when you use run.