GAE 1.6 can not import module jinja2

618 views
Skip to first unread message

Kai

unread,
Nov 8, 2011, 10:55:07 AM11/8/11
to google-a...@googlegroups.com
I am trying my first python2.7 GAE apps. Everything goes smoothly in the GAE python2.7 Getting Started guild, except the chapter Using Templates.

I have added the lines in my app.yaml:
libraries:
- name: jinja2
  version
: latest

I have also changed my helloworld.py to import jinja2 module.
And errors:
ERROR    2011-11-08 15:01:12,371 wsgi.py:170] 
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 168, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 206, in _LoadHandler
    handler = __import__(path[0])
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate
    return func(self, *args, **kwargs)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1756, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate
    return func(self, *args, **kwargs)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1628, in FindAndLoadModule
    description)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate
    return func(self, *args, **kwargs)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1571, in LoadModuleRestricted
    description)
  File "/Users/kai/Documents/AppEngine/helloworld/helloworld.py", line 1, in <module>
    import jinja2
ImportError: No module named jinja2

How can I use jjinja2 template engine in the GAE 1.6 SDK?

NG

unread,
Nov 8, 2011, 3:45:56 PM11/8/11
to google-a...@googlegroups.com
Same here

Matt Jibson

unread,
Nov 8, 2011, 5:08:54 PM11/8/11
to google-a...@googlegroups.com
Have you installed jinja2 locally? Historically, the SDK has not
included 3rd party libraries (PIL was the first example). They had to
be installed on your own machine, and the SDK would be able to import
them.

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/bQBghm-hawAJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

Brian Quinlan

unread,
Nov 8, 2011, 6:39:55 PM11/8/11
to google-a...@googlegroups.com
As Matt says, you need to install jinja2 on your local Python instance.

This will be fixed in a future release.

Cheers,
Brian

On Wed, Nov 9, 2011 at 7:45 AM, NG <nikolas...@googlemail.com> wrote:
> Same here


>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/google-appengine/-/BDGGzz0ahFMJ.

Kai

unread,
Nov 8, 2011, 7:45:25 PM11/8/11
to Google App Engine
Thank you, Matt and Brian.
Actually, I have not installed jinja2 in my system. I will try to
fixed this minor issue and finish the tutorial guild. :)

speg

unread,
Dec 2, 2011, 10:08:13 PM12/2/11
to Google App Engine
How are we supposed to know this? I jumped into GAE with the 2.7
tutorial and there was no mention of installing packages locally. I
thought it was all bundled in GAE.

Brian Quinlan

unread,
Dec 5, 2011, 6:48:46 AM12/5/11
to google-a...@googlegroups.com
On Sat, Dec 3, 2011 at 2:08 PM, speg <steveh...@gmail.com> wrote:
> How are we supposed to know this?  I jumped into GAE with the 2.7
> tutorial and there was no mention of installing packages locally.  I
> thought it was all bundled in GAE.

The fact that required pure-Python modules are not packaged with the
SDK is simply a bug. Installing it yourself is the work-around.

Cheers,
Brian

Albert Woo

unread,
Jan 5, 2012, 4:46:07 AM1/5/12
to google-a...@googlegroups.com
I did it.

steve

unread,
Jan 16, 2012, 11:24:47 PM1/16/12
to google-a...@googlegroups.com
I installed it locally and I am still unable to import jinja2, it is giving me the import jinja2 error every time.

N. Rosencrantz

unread,
Jan 17, 2012, 1:39:03 AM1/17/12
to google-a...@googlegroups.com
If you do

import jinja2

you must download jinja2 and keep it in the app directory and it will work. The correct way of doing it however is to my knowledge

from webapp2_extras import jinja2

then you don't need the local library since you're importing from webapp2. It may depend on whether you want to use webapp2 or some other framework. I hope this works for you too.
Regards,
Nick
Reply all
Reply to author
Forward
0 new messages