NameError: el nombre 'hasattr' no está definido: Python3.6, Django1.11, Ubuntu16-17, Apache2.4, mod_wsgi

He configurado mi entorno virtual Python / Django y mod_wsgi en modo demonio, y estoy bastante seguro (hecho esto antes) de que es "mayormente correcto"excepto que aparece el siguiente error ...

[Thu Jul 06 00:35:26.986363 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00493: SIGUSR1 received.  Doing graceful restart
Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 00:35:27.194483 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming normal operations
[Thu Jul 06 00:35:27.194561 2017] [core:notice] [pid 11442:tid 140557758930432] AH00094: Command line: '/usr/sbin/apache2'

Mi aplicación django se está cargando bien a través de wsgi.py, pero parece que algo relacionado con el núcleo de Python (error con mi configuración probable) está yendo mal según:NameError: name 'hasattr' is not defined

En el navegador, obtengo una página simple de "Error de servidor (500)" y no la página estándar de "Error interno del servidor" de Apache.

Dejar de lado mi VirtualHost y los pasos más allá de aquí son los pasos básicos que preparé para mí si puedes detectar algo ... (También he probado todos los diferentes paquetes de Python, no solo -venv)

Install Python 3.6 and virtualenv
    sudo apt-get update
    sudo apt-get install python3.6-venv
    sudo apt-get install virtualenv
(or find the latest and greatest python package that includes pip https://packages.ubuntu.com/ )


Install Apache2
    sudo apt-get install apache2 apache2-dev


Make and enter a folder for your project - then build a Virtual Environment in it
    mkdir ~/example.com
    cd ~/example.com
    virtualenv --python=/usr/bin/python3.6 py361ve

Enter your new Virtual Environment to install packages to it
    source py361ve/bin/activate

Install Django, mod_wsgi, and any other needed packages
    pip install django
    pip install mod_wsgi
    pip install ...
(no need for pip3 in virtual environment - django should be the latest release)


Run following command and place output in apache config file ( in /etc/apache2/ )
    mod_wsgi-express module-config


Exit your virtual environment
    deactivate
(You can re-enter your virtual environment any time using the source method in step 8)

Esto es lo que sucede cuando detengo / inicio / reinicio apache2 ...

apache2 stop...

[Thu Jul 06 06:01:34.190940 2017] [mpm_event:notice] [pid 2015:tid 140157449797120] AH00491: caught SIGTERM, shutting down
_______________________________________________________________
apache2 start...

[Thu Jul 06 06:02:39.076741 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:02:39.076890 2017] [core:notice] [pid 2181:tid 140553545080320] AH00094: Command line: '/usr/sbin/apache2'
_______________________________________________________________
apache2 restart...

Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 06:05:43.307877 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00491: caught SIGTERM, shutting down
[Thu Jul 06 06:05:43.492499 2017] [mpm_event:notice] [pid 2301:tid 140353155558912] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:05:43.492705 2017] [core:notice] [pid 2301:tid 140353155558912] AH00094: Command line: '/usr/sbin/apache2'

Respuestas a la pregunta(3)

Su respuesta a la pregunta