Problem with deploying through mod_wsgi (SyntaxError in decorator.py)

52 views
Skip to first unread message

Kai H.

unread,
Mar 24, 2014, 8:53:36 PM3/24/14
to turbo...@googlegroups.com
Hello guys,

i try to run my app via mod_wsgi. The apache server starts but i get an Internal Server Error (500) when trying to access the webapp. (The behavior is the same for a simple gearbox example app, so i assume the problem is not related to my app).

I followed this section: http://turbogears.readthedocs.org/en/latest/cookbook/deploy/mod_wsgi.html

Any suggestions? Is maybe something missing in the .ini-file?



The Apache error log says:

[Tue Mar 25 00:45:28 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Mar 25 00:45:28 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Mar 25 00:45:28 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Mar 25 00:45:28 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Mar 25 00:45:28 2014] [notice] Apache/2.2.22 (Debian) PHP/5.4.4-14+deb7u8 mod_ssl/2.2.22 OpenSSL/1.0.1e mod_wsgi/3.3 Python/3.2.3 mod_perl/2.0.7 Perl/v5.14.2 configured -- res
uming normal operations
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X] mod_wsgi (pid=1466): Target WSGI script '/home/kai/tg232env/myapp/app.wsgi' cannot be loaded as Python module.
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X] mod_wsgi (pid=1466): Exception occurred processing WSGI script '/home/kai/tg232env/myapp/app.wsgi'.
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X] Traceback (most recent call last):
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/myapp/app.wsgi", line 9, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     application = loadapp('config:%s' % APP_CONFIG)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     return loadobj(APP, uri, name=name, **kw)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 271, in loadobj
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     global_conf=global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     global_conf=global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     return loader.get_context(object_type, name, global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     section)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     object_type, name=use, global_conf=global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     global_conf=global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     global_conf=global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     return loader.get_context(object_type, name, global_conf)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     object_type, name=name)
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     possible.append((entry.load(), protocol, entry.name))
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/pkg_resources.py", line 2088, in load
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     entry = __import__(self.module_name, globals(),globals(), ['__name__'])
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/myapp/myapp/config/middleware.py", line 4, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     from myapp.config.app_cfg import base_config
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/myapp/myapp/config/app_cfg.py", line 9, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     from tg.configuration import AppConfig
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/tg/__init__.py", line 55, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     from tg.request_local import app_globals, request, response, tmpl_context, session, cache, translator
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/tg/request_local.py", line 4, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     from tg.caching import cached_property
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/tg/caching.py", line 3, in <module>
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     from decorator import decorator
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]   File "/home/kai/tg232env/lib/python2.7/site-packages/decorator.py", line 156
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]     exec code in evaldict
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X]             ^
[Tue Mar 25 00:45:56 2014] [error] [client X.X.X.X] SyntaxError: invalid syntax

Alessandro Molina

unread,
Mar 25, 2014, 5:19:33 AM3/25/14
to TurboGears .
Could you check the python version apache is actually using? I see that the virtualenv is for Python2.7 but it might be that mod_wsgi is linked to another python version causing  some oddities. 


--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Kai H.

unread,
Mar 25, 2014, 6:51:32 AM3/25/14
to turbo...@googlegroups.com
Hey Alessandro,

thank you for answering!

I already rebuilt mod_wsgi, because with the version from debian package management apache throwed an error like "Python version mismatch, expected '2.7.2+', found '2.7.3'". It seemed to be successful, since this message disappeared. But now i'm stuck on this... Is this the problem you were expecting or do you mean something else?

Btw: Do i need mod_python?

Thank you!

Alessandro Molina

unread,
Mar 25, 2014, 6:55:32 AM3/25/14
to TurboGears .
You don't need mod_python, mod_wsgi is correct.
The issue is that you might have built mod_wsgi linking to Python3 which doesn't support the "exec" statement and so it throws a SyntaxError.

decorator supports Python3, but it does so but using 2to3 at install time. As you created the virtualenv with python2.7 the code installed at setup is for python2 series, but you are trying to run it on python3.

Make sure you built mod_wsgi for the right python version (2.7)

Kai H.

unread,
Mar 25, 2014, 8:20:02 AM3/25/14
to turbo...@googlegroups.com
Yey! Thanks Alessandro!

Somehow the package libapache2-mod-wsgi-py3 was installed aswell and used instead of the 2.7-version. After removing it, and installing my self-built-deb again, it finally works!

Thanks alot!
Reply all
Reply to author
Forward
0 new messages