35

Using google-app-engine tutorial, I got the following error stack message:

Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "D:\Dev\SandBoxes\web\omaha\omaha.py", line 4, in <module>
import jinja2
ImportError: No module named jinja2

Even though I declared it in the libraries from app.yaml:

application: ***
version: 1
runtime: python27
api_version: 1
threadsafe: true

libraries:
- name: jinja2
  version: latest
- name: webapp2
  version: latest


handlers:
- url: /css
  static_dir: css
- url: /js
  static_dir: js
- url: /img
  static_dir: img
- url: /.*
  script: omaha.application

Has anyone had a similar problem?

0

8 Answers 8

37

In order to use Jinja locally, you need to install it locally

easy_install Jinja2

or

pip install Jinja2
3
  • 5
    or with your package manager (in Linux) something like one of these: apt-get install python-jinja2 (debian/ubuntu) or yum install python-jinja2 (redhat) or zypper install python-Jinja2(suse) ` and/or possibly python3- variants of these
    – mike
    Commented Aug 21, 2014 at 12:42
  • Actually, when you install GAE sdk jinja2 is coming together, so no need to install it from other sources.
    – Cyril
    Commented Aug 22, 2014 at 7:23
  • 1
    This answer is wrong, GAE apps use jinja2 from the SDK, not from the local system python installation. Commented Aug 26, 2017 at 0:34
7

Need to restart application in AEL.

The application in Google App Engine Launcher must be restarted for new library calls to be taken into account. I was mislead by the fact all other changes dont need actual restart of the server.

6

Use these commands to get pip and Jija2 installed for Python 3:

sudo apt-get install python3-pip
sudo pip3 install Jinja2
1
  • The OP is clearly tagged with python-2.7, the only one supported on GAE standard environment... Commented Aug 26, 2017 at 0:28
5

You may not have added the following lines to app.yaml:

- name: jinja2
  version: latest
3
brew install jinja2-cli

for them brew users

1
  • this only helped me
    – Denis
    Commented Jan 19 at 23:40
1

Please lower the version for jinja.This worked for me.

pip install Jinja2==3.0.3

0

Even though it's declared in your libraries it doesn't necessarily mean the dev app server can find the library within the appengine sdk.

Since you're running the tutorial, I'm assuming you are running the application from googles app engine launcher. Within the laucher go into "Edit" >> "Prefences" and set your Python Path and SDK Path.

enter image description here

0

I had this error when the flask package threw this error:

import flask
  File "/usr/local/lib/python2.7/dist-packages/flask/__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
ImportError: No module named jinja2

Solution:

sudo apt-get install python-flask

It seems to install Jinja as a dependency. Perhaps this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.