If you follow the Python2.7 getting started guide, you get to the templating part here. For me on Ubuntu 11.10 I would get a horrible stack trace that ended with:
File "/home/fratrik/code/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1571, in LoadModuleRestricted
description)
File "/usr/lib/python2.7/dist-packages/jinja2/utils.py", line 587, in <module>
from jinja2._markupsafe import Markup, escape, soft_unicode
ImportError: No module named _markupsafe
The important part is actually at the top:
ERROR 2011-11-13 00:48:12,767 dev_appserver_import_hook.py:1386] Third party package markupsafe must be included in the "libraries:" clause of your app.yaml file in order to be imported.
The answer is to add the following to your app.yaml
libraries:
- name: jinja2
version: latest
- name: markupsafe
version: latest
(for python2.7)
You can import the jinja2 module that is coming with the app engine sdk.
Add the path of google_appengine/lib/webapp2
and google_appengine/lib/webapp2/webapp2_extras
directories to your $PYTHONPATH
.
import webapp2
from webapp2_extras import jinja2
along with the yaml entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With