0

I am using Python 3.2.3. And I installed Jinja2.5 by downloading from this page: https://pypi.python.org/pypi/Jinja2/2.5.5

Then I used the setup.py to install it. This seemed worked like a charm. When I tested it by using this line:

from jinja2 import Template

I got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/Jinja2-2.5.5-py3.2.egg/jinja2/__init__.py", line 37, in <module>
    from jinja2.environment import Environment, Template
  File "/usr/local/lib/python3.2/dist-packages/Jinja2-2.5.5-py3.2.egg/jinja2/environment.py", line 13, in <module>
    from jinja2 import nodes
  File "/usr/local/lib/python3.2/dist-packages/Jinja2-2.5.5-py3.2.egg/jinja2/nodes.py", line 18, in <module>
    from jinja2.utils import Markup, MethodType, FunctionType
  File "/usr/local/lib/python3.2/dist-packages/Jinja2-2.5.5-py3.2.egg/jinja2/utils.py", line 585, in <module>
    from markupsafe import Markup, escape, soft_unicode
  File "/usr/local/lib/python3.2/dist-packages/markupsafe/__init__.py", line 70
    def __new__(cls, base=u'', encoding=None, errors='strict'):
                            ^
SyntaxError: invalid syntax

This is on my Raspberry pi with Raspbian installed. I don't know why this error occures, because the docs say Jinja2.5 and Python 3.2 are compatible.

Can anyone help me out? Thanks in advance!

1 Answer 1

0

Try typing python --version if the reply does not say Python 3. something then your default python is python 2 and so does not support u'' for unicode strings.

If this is the case you need to install jinja2 by using pip3 install jinja2 and run your scripts with python3 scriptname.py.

Other than that see: Syntax error in jinja 2 library basically python 3.2 is no longer supported so the choice is pick another library or upgrade python.

5
  • I used the following command to test this: sudo pip3.2 install jinja2. This said it was already installed. I also always on purposely type: python3.2 to make sure I have the right version Nov 9, 2014 at 12:36
  • Have you tried the current version of jinja2 - as of today I make it 2.7.2. Nov 9, 2014 at 12:44
  • As stated in the Jinja docs: "support for Python 3.2 was dropped in Jinja2 version 2.7" Nov 9, 2014 at 12:45
  • 1
    looks like you are not the only one with this problem: stackoverflow.com/questions/18252804/… - the accepted answer there was either pick another library or upgrade to python3.3. Nov 9, 2014 at 12:51
  • Hmm, I guess I will have to pick another library then. Thanks for the help anyway! Nov 9, 2014 at 13:04

Your Answer

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

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