I have a Google App Engine application that makes a BigQuery request. I use json.dumps to deal with the data and now I am trying to pass the JSON object to an HTML template to send via email. I found this Python module, json2html, that I would like to use but I am receiving an error message:
ImportError No module named json2html
BigQuery results:
[
{'Color': u'red', 'Date': '12/12/12', 'Id': 188},
{'Color': u'orange', 'Date': '03/25/12', 'Id': 360},
{'Color': u'yellow', 'Date': '08/17/12', 'Id': 258},
{'Color': u'green', 'Date': '01/02/12', 'Id': 291},
{'Color': u'red', 'Date': 'N/A', 'Id': 895},
{'Color': u'blue', 'Date': 'N/A', 'Id': 347},
{'Color': u'orange', 'Date': 'N/A', 'Id': 923}
]
Python:
import json
from json2html import *`
def myfunction(self):
items = Item.query().fetch()
my_list = []
for x in items:
....
my_list.append()
result = json.dumps(my_list, default=str, sort_keys=True, indent=4)
conv_result = json2html.convert(result)
return conv_result
def get(self):
my_results = self.myfunction()
send_message('{}@appspot.gserviceaccount.com'.format(
app_identity.get_application_id()), my_results)
self.response.content_type = 'text/plain'
What I've done so far:
I'm not sure if this issue relates to Google App Engine in any way or what the issue might be. Any ideas?
I have a Google App Engine application that makes a BigQuery request. I use json.dumps to deal with the data and now I am trying to pass the JSON object to an HTML template to send via email. I found this Python module, json2html, that I would like to use but I am receiving an error message:
ImportError No module named json2html
BigQuery results:
[
{'Color': u'red', 'Date': '12/12/12', 'Id': 188},
{'Color': u'orange', 'Date': '03/25/12', 'Id': 360},
{'Color': u'yellow', 'Date': '08/17/12', 'Id': 258},
{'Color': u'green', 'Date': '01/02/12', 'Id': 291},
{'Color': u'red', 'Date': 'N/A', 'Id': 895},
{'Color': u'blue', 'Date': 'N/A', 'Id': 347},
{'Color': u'orange', 'Date': 'N/A', 'Id': 923}
]
Python:
import json
from json2html import *`
def myfunction(self):
items = Item.query().fetch()
my_list = []
for item in items:
dict_item = dict()
dict_item['Color'] = item.ItemColor
dict_item['Date'] = item.ItemSoldDate
dict_item['Id'] = item.ItemId
my_list.append(dict_item)
result = json.dumps(my_list, default=str, sort_keys=True, indent=4)
conv_result = json2html.convert(result)
return conv_result
def get(self):
my_results = self.myfunction()
send_message('{}@appspot.gserviceaccount.com'.format(
app_identity.get_application_id()), my_results)
self.response.content_type = 'text/plain'
Full Traceback:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/xxxxxxxxxx/xxxxxxxxxx/main.py", line 31, in <module>
from json2html import *
ImportError: No module named json2html
1) I have found posts for the error: ImportError: No module named 'jsonconv', but have found nothing for this specific error.
2) I've installed the json2html via Pycharm, pip, and also forked the json2html project from Github. Nothing worked.
pip install json2html
Requirement already satisfied: json2html in /Users/xxxxxxxxxx/anaconda/lib/python2.7/site-packages