Cannot import the Template class of Mako. Have a SyntaxError error in “\mako\template.py”, line 622

66 views
Skip to first unread message

A B

unread,
Feb 8, 2013, 9:08:14 PM2/8/13
to mako-d...@googlegroups.com
Hello.

I want to try Mako with Django instead of Django's default template language. But I'm having a problem when I try to import Makos's Template class as written in the manual:

from mako.template import Template mytemplate
mytemplate = Template("hello world!")
print mytemplate.render()

I do this in Windows cmd and receive such an error:
C:\Documents and Settings\User>cd C:\py\project\vendor\template\Mako_73 // cd to where I unpacked Mako
C:\py\project\vendor\template\Mako_73>python // run Python interpreter
>>> from mako.template import Template // trying to import and getting an error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\mako\template.py", line 622
exec code in module.__dict__, module.__dict__
^
SyntaxError: invalid syntax


What can it be? I couldn't find anything in Google about this error.

I'm using Python 3.3.

I've downloaded Mako-0.7.3 as tar.gz file and just unzipped it inC:\py\poject\vendor\template\Mako_73. I do not have this directory in the PYTHONPATH or paths.pth. C:\py\poject is a directory where my Django project lives and in \vendor\template I've decided to put Mako and import it from there.

The same question on Stackoveflow.


A B

unread,
Feb 8, 2013, 9:11:35 PM2/8/13
to mako-d...@googlegroups.com
The system changed the position of the pointer on the error. It is under "e" of "code" word.
exec code in module.__dict__, module.__dict__
        ^

суббота, 9 февраля 2013 г., 4:08:14 UTC+2 пользователь A B написал:

Michael Bayer

unread,
Feb 9, 2013, 11:14:07 AM2/9/13
to mako-d...@googlegroups.com
Mako up until the current version requires that it be installed using Python 2to3 (this has been changed in 0.7.4 which is not yet released).

You need to either install Mako which will run 2to3 automatically or run "2to3 -w mako" to rewrite the files in place if you don't want to actually install them anywhere.   I'd recommend an install though, at least into a virtual environment.


Reply all
Reply to author
Forward
0 new messages