How to overcome “datetime.datetime not JSON serializable” in python?
a simple solution based on a specific serializer that just converts
datetime.datetime objects to strings:
def default(o):
if type(o) is datetime.date or type(o) is datetime.datetime:
return o.isoformat()
raise TypeError ("Type not serializable")
def jsondumps(o):
return json.dumps(o, default=default)
or
In your call do something like: json.dumps(yourobj, cls=DateTimeEncoder)
from datetime import datetimeimport json
class DateTimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
return json.JSONEncoder.default(self, o)
“IOError: decoder zip not available”
There are many situations for this problem.The follows solution works for me.(CentOs 6.5 Final)
pip uninstall PIL
pip install PIL
try to reinstall PIL, and pay attention to the output info after you reinstalled:
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2]
-----------------------------------------------------------------------
TKINTER support available
*** JPEG support not available---
ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available