End of script output before headers: wsgi.py
Question: I am trying to install my django project with Apache, mod_wsgi and python3.  
but Apache still gives this error:

    
    
    Exception ignored in: <module 'threading' from    '/usr/lib/python3.4/threading.py'>
    Traceback (most recent call last):
    File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
    assert tlock is not None
    AssertionError:
    End of script output before headers: wsgi.py
    

I lost two days trying to fix this problem, I know that this error can be
produced by several reasons but I not find where the problem.

Here the **wsgi.py** content:

    
    
    #!/usr/bin/python3
    # -*- coding: utf-8 -*-
    
    
    import os
    import site, sys
    
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    if path not in sys.path:
        sys.path.append(path)
    sys.path.append('/var/www/myproject/myproject_env/bin/python3.4/dist-packages')
    site.addsitedir('/var/www/myproject/myproject_env/bin/python3.4/dist-packages')
    
    os.environ["DJANGO_SETTINGS_MODULE"] = "myproject.settings"
    
    from django.core.wsgi import get_wsgi_application
    
    application = get_wsgi_application()
    

The Apache configuration is as follows:

    
    
    <VirtualHost *:80>
    
        ServerName  mydomain.com
        ServerAlias www.mydomain.com
    
        DocumentRoot /var/www
    
        Alias /static/ /var/www/myproject/static/
        Alias /static/admin/ /var/www/myproject/static/admin/
        Alias /uploads/ /var/www/myproject/uploads/
    
        WSGIDaemonProcess myproject lang='fr_FR.UTF-8' locale='fr_FR.UTF-8' python-path=/var/www/myproject:/var/www/myproject/myproject_env/bin/python3.4/dist-packages
        WSGIProcessGroup myproject
        WSGIScriptAlias / /var/www/myproject/myproject/wsgi.py
        WSGIApplicationGroup %{GLOBAL}
    
         <Directory "/var/www/myproject/myproject/">
                Require all granted
        </Directory>
        <Directory "/var/www/myproject/myproject/wsgi.py">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Require all granted
        </Directory>
    
        <Directory /static/admin/>
    
                Require all granted
        </Directory>
        <Location "/uploads/">
                SetHandler None
        </Location>
    
        ErrorLog /var/log/apache2/myproject.log
        CustomLog /var/log/apache2/myproject.access.log combined
    </VirtualHost>
    

Please anyone helps me fix this?


Answer: **Solved** : I changed the location of my Django project to another folder in
a new linux account. I think (and I'm not really sure) the error occurred
because **/var/www** contains another python project using cgi-bin, this maybe
creates conflict with my Django project.

