0

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

Community
  • 1
  • 1
A.Raouf
  • 2,171
  • 1
  • 24
  • 36
  • Could be Python version, some library problem or something else. But what I can tell you is that when you use `manage.py runserver` you are not using Apache & WSGI at all - so one can work where the other doesn't. – manassehkatz-Moving 2 Codidact Nov 28 '17 at 17:38
  • from typing import NamedTuple is present from python 3.5 onwards. Here is the link for reference, https://stackoverflow.com/questions/34269772/type-hints-in-namedtuple – Akash Wankhede Nov 28 '17 at 17:44
  • Possible duplicate of [Install mod\_wsgi on Ubuntu with Python 3.6, Apache 2.4, and Django 1.11](https://stackoverflow.com/questions/44914961/install-mod-wsgi-on-ubuntu-with-python-3-6-apache-2-4-and-django-1-11) – ben author Nov 28 '17 at 17:44
  • I edited the question that my OS is Redhat 7 and I'm trying your suggested solutions – A.Raouf Nov 28 '17 at 18:41

1 Answers1

1

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.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134