32

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?

Ray
  • 2,472
  • 18
  • 22
Cyril
  • 741
  • 1
  • 6
  • 16

8 Answers8

37

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

easy_install Jinja2

or

pip install Jinja2
topless
  • 8,069
  • 11
  • 57
  • 86
  • 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 Aug 21 '14 at 12:42
  • Actually, when you install GAE sdk jinja2 is coming together, so no need to install it from other sources. – Cyril Aug 22 '14 at 07:23
  • 1
    This answer is wrong, GAE apps use `jinja2` from the SDK, not from the local system python installation. – Dan Cornilescu Aug 26 '17 at 00: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.

Cyril
  • 741
  • 1
  • 6
  • 16
5

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

- name: jinja2
  version: latest
Kees Briggs
  • 351
  • 3
  • 12
4

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

sudo apt-get install python3-pip
sudo pip3 install Jinja2
user3546879
  • 422
  • 4
  • 11
2
brew install jinja2-cli

for them brew users

Ivan Yulin
  • 794
  • 7
  • 15
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

Jesse
  • 8,223
  • 6
  • 49
  • 81
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.

questionto42
  • 7,175
  • 4
  • 57
  • 90
0

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

pip install Jinja2==3.0.3

Alan
  • 9
  • 1