import mako.template import mako.lookup import mako.exceptions import os # must have module_directory specified for bug to surface template_finder = mako.lookup.TemplateLookup( directories = os.path.join(os.getcwd(), 'templates'), module_directory = os.path.join(os.getcwd(), 'cache'), ) my_template = template_finder.get_template("my_template.html") try: print(my_template.render()) except: print("Template exception: {0}".format(mako.exceptions.text_error_template().render()))