A.Raouf
A.Raouf

Reputation: 2320

SyntaxError at django with Apache and wsgi

This is error_log file of httpd when running the django app

File "/var/www/html/mailqenv/lib/python3.4/site-packages/celery/utils/functional.py", line 11, in <module>
[Tue Nov 28 21:26:18.349280 2017] [:error] [pid 3665] [remote 41.187.94.200:84]     from kombu.utils.functional import (
[Tue Nov 28 21:26:18.349296 2017] [:error] [pid 3665] [remote 41.187.94.200:84]   File "/var/www/html/mailqenv/lib/python3.4/site-packages/kombu/utils/__init__.py", line 5, in <module>
[Tue Nov 28 21:26:18.349322 2017] [:error] [pid 3665] [remote 41.187.94.200:84]     from .compat import fileno, maybe_fileno, nested, register_after_fork
[Tue Nov 28 21:26:18.349333 2017] [:error] [pid 3665] [remote 41.187.94.200:84]   File "/var/www/html/mailqenv/lib/python3.4/site-packages/kombu/utils/compat.py", line 29, in <module>
[Tue Nov 28 21:26:18.349350 2017] [:error] [pid 3665] [remote 41.187.94.200:84]     from typing import NamedTuple
[Tue Nov 28 21:26:18.349400 2017] [:error] [pid 3665] [remote 41.187.94.200:84]   File "/var/www/html/mailqenv/lib/python3.4/site-packages/typing.py", line 133
[Tue Nov 28 21:26:18.349408 2017] [:error] [pid 3665] [remote 41.187.94.200:84]     def __new__(cls, name, bases, namespace, *, _root=False):
[Tue Nov 28 21:26:18.349412 2017] [:error] [pid 3665] [remote 41.187.94.200:84]                                               ^
[Tue Nov 28 21:26:18.349416 2017] [:error] [pid 3665] [remote 41.187.94.200:84] SyntaxError: invalid syntax

The conf file of httpd:

Alias /static /var/www/html/mailqueue/static
<Directory /var/www/html/mailqueue/static>
    Require all granted
</Directory>

<Directory /var/www/html/mailqueue/mailqueue>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>


<Directory /var/www/html/mailqueue>
        Order deny,allow
        Allow from all
</Directory>

WSGIDaemonProcess mailqueue python-path=/var/www/html/mailqueue:/var/www/html/mailqenv/lib/python3.4/site-packages
WSGIProcessGroup mailqueue
WSGIScriptAlias / /var/www/html/mailqueue/mailqueue/wsgi.py`

OS > PRETTY_NAME="Red Hat Enterprise Linux Server 7.2 (Maipo)"

But if I activated my virtual environment and run with python manage.py runserver 0.0.0.0:8000 it works well and all is good so what is the problem here, is it python version compatibility

Update ----------

I tried the answer of this question of stackoverflow and in vain

Upvotes: 0

Views: 822

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58523

This error arises because your mod_wsgi is compiled for Python 2.7, but you have pointed it at a Python virtual environment and code which is Python 3.X. The keyword only syntax does not exist in Python 2.7.

You need to install mod_wsgi which has been compiled against Python 3.X version you want to use. You cannot force mod_wsgi compiled for one version to use a Python virtual environment for a different Python version.

You can use the checks in:

to verify what version of Python your mod_wsgi is compiled for.

Also review:

for the recommended way of using a virtual environment with mod_wsgi. You currently don't use the recommended way.

Upvotes: 1

Related Questions