I am getting a weird error while trying to run my Django site under Apache using mod_wsgi. I have been working on this for hours to no avail.
FYI: I am also using Mezzanine.
Log:
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Target WSGI script '/opt/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Exception occurred processing WSGI script '/opt/mysite/mysite/wsgi.py'.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] Traceback (most recent call last):
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/opt/mysite/mysite/wsgi.py", line 12, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.core.wsgi import get_wsgi_application
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/__init__.py", line 3, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.utils.version import get_version
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/utils/version.py", line 7, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.utils.lru_cache import lru_cache
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] SyntaxError: invalid syntax
httpd.conf for mysite (there are others on the server)
# Redirects all HTTP traffic to HTTPS
<VirtualHost *:80>
#ServerName test-mysite
#ServerAlias test-mysite mysite.com mysite
ServerName mysite.com
ServerAlias mysite test-mysite.com test-mysite
DocumentRoot /opt/mysite
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
WSGIScriptAlias / /opt/mysite/mysite/wsgi.py
</VirtualHost>
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:443>
#ServerName test-mysite.com
#ServerAlias test-mysite
ServerName mysite.com
ServerAlias mysite test-mysite.com test-mysite
ErrorLog /var/log/httpd/ssl_mysite_error_log
CustomLog /var/log/httpd/ssl_mysite_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
TransferLog /var/log/httpd/ssl_mysite_access_log
LogLevel warn
WSGIDaemonProcess mysite.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup mysite.com
WSGIScriptAlias / /opt/mysite/mysite/wsgi.py
<Directory /opt/mysite/mysite>
Options +FollowSymLinks -Indexes
AllowOverride All
order allow,deny
allow from all
</Directory>
SSLEngine On
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/othersite_com.crt
SSLCertificateKeyFile /etc/pki/tls/private/othersite.com.key
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
</VirtualHost>
httpd -V output:
Server version: Apache/2.2.15 (Unix)
Server built: Jul 12 2016 07:03:49
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
How do I fix this?
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] SyntaxError: invalid syntax
Python 2.6 doesn't support set syntax {....}
You may use a version of Django that supports Python 2.6 but make sure it also supports Mezzanine
OR
Update your Python installation to 2.7
Related
I'm trying to run a simple Flask web app that displays a pygal graph. When I run it with the python development server, the application runs fine. However, when I try to run it in apache2, I get the following error:
[Thu Dec 10 19:55:22.745469 2020] [wsgi:error] [pid 17741] [client ::1:34366] mod_wsgi (pid=17741): Failed to exec Python script file '/var/www/FlaskApp/FlaskApp.wsgi'.
[Thu Dec 10 19:55:22.745521 2020] [wsgi:error] [pid 17741] [client ::1:34366] mod_wsgi (pid=17741): Exception occurred processing WSGI script '/var/www/FlaskApp/FlaskApp.wsgi'.
[Thu Dec 10 19:55:22.745553 2020] [wsgi:error] [pid 17741] [client ::1:34366] Traceback (most recent call last):
[Thu Dec 10 19:55:22.745586 2020] [wsgi:error] [pid 17741] [client ::1:34366] File "/var/www/FlaskApp/FlaskApp.wsgi", line 8, in <module>
[Thu Dec 10 19:55:22.745650 2020] [wsgi:error] [pid 17741] [client ::1:34366] from FlaskApp import app as application
[Thu Dec 10 19:55:22.745665 2020] [wsgi:error] [pid 17741] [client ::1:34366] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 2, in <module>
[Thu Dec 10 19:55:22.745707 2020] [wsgi:error] [pid 17741] [client ::1:34366] import pygal
[Thu Dec 10 19:55:22.745723 2020] [wsgi:error] [pid 17741] [client ::1:34366] File "/var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages/pygal/__init__.py", line 28, in <module>
[Thu Dec 10 19:55:22.745786 2020] [wsgi:error] [pid 17741] [client ::1:34366] import pkg_resources
[Thu Dec 10 19:55:22.745838 2020] [wsgi:error] [pid 17741] [client ::1:34366] File "/var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1365
[Thu Dec 10 19:55:22.745850 2020] [wsgi:error] [pid 17741] [client ::1:34366] raise SyntaxError(e) from e
[Thu Dec 10 19:55:22.745857 2020] [wsgi:error] [pid 17741] [client ::1:34366] ^
[Thu Dec 10 19:55:22.745864 2020] [wsgi:error] [pid 17741] [client ::1:34366] SyntaxError: invalid syntax
Here is the code that I'm running
# -*- coding: utf-8 -*-
import pygal
from flask import Flask, Response
app = Flask(__name__)
#app.route('/')
def index():
""" render svg on html """
return """
<html>
<body>
<h1>hello pygal</h1>
<figure>
<embed type="image/svg+xml" src="/graph/" />
</figure>
</body>
</html>'
"""
#app.route('/graph/')
def graph():
""" render svg graph """
bar_chart = pygal.Bar()
bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55])
return Response(response=bar_chart.render(), content_type='image/svg+xml')
if __name__ == '__main__':
app.run()
(Note that this code is just a sample copied from github)
Here is my apache site configuration:
<VirtualHost *:443>
ServerName flaskapp.localhost
ServerAdmin me#email.com
WSGIScriptAlias / /var/www/FlaskApp/FlaskApp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
DocumentRoot /var/www/FlaskApp
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
ErrorLog ${APACHE_LOG_DIR}/FlaskApp-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/FlaskApp-access.log combined
AddDefaultCharset utf-8
</VirtualHost>
Here is my wsgi file:
python_home = '/var/www/FlaskApp/FlaskApp/venv'
activate_this = python_home + '/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
sys.path.insert(0,"/var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages/")
from FlaskApp import app as application
application.secret_key = 'secret key stuff'
Here are some details about my environment:
Ubuntu 20.04.1 LTS
Apache/2.4.41 (Ubuntu)
Python 3.8.5 (installed in a virtual environment)
Any thoughts would be greatly appreciated!
It appears that the python interpreter is compiled into the mod_wsgi.so file. An old version, that included python2, was being pointed to by Apache. To fix it I did the following:
Removed the old version of mod_wsgi by doing sudo apt-get remove libapache2-mod-wsgi
modified /etc/apache2/mods-available/mod_wsgi.load to point to the library (.so) file in my virtual environment. The contents of mod_wsgi looked like this:
LoadModule wsgi_module /var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so
I suspect that modifying it here points all Apache virtual hosts to this python virtual environment, which isn't really ideal. It would be better if each Apache virtual host pointed to its own python environment.
Modified my wsgi file to work with the new version of python. Here are the contents:
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
sys.path.insert(0,"/var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages/")
from FlaskApp import app as application
application.secret_key = 'secret key stuff'
Changed the local imports in my __init__.py file to be preceeded by a dot(.)
Following these changes the site is now working as expected.
I'm trying to configure Apache to delploy my Flask app. It works if i run command "python flaskapp.py", but with Apache it can not import internal module Tools
This is my flask app
from flask import Flask
app = Flask(__name__)
import sys
sys.path.append('tools')
import Tools #if i comment this line, not error display and app works ok!
#app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
This is my .conf file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp python-path=/var/www/html/flaskapp
WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi process-group=flaskapp application-group=%{GLOBAL}
<Directory /var/www/html/flaskapp>
<Files flaskapp.wsgi>
Order allow,deny
Allow from all
</Files>
</Directory>
Alias /static /var/www/html/flaskapp/static
<Directory /var/www/html/flaskapp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
My wsgi file
import sys
sys.path.insert(0, '/var/www/html/flaskapp')
from flaskapp import app as application
My app folders ar /var/www/html/
flaskapp/
-flaskapp.py
-flaskapp.wsgi
-static/
-templates/
-tools/
-Tools.py
Error log
[Thu Mar 09 18:23:23.634661 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] mod_wsgi (pid=3711): Target WSGI script '/var/www/html/flaskapp/flaskapp.wsgi' cannot be loaded as Python module.
[Thu Mar 09 18:23:23.634694 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] mod_wsgi (pid=3711): Exception occurred processing WSGI script '/var/www/html/flaskapp/flaskapp.wsgi'.
[Thu Mar 09 18:23:23.634719 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] Traceback (most recent call last):
[Thu Mar 09 18:23:23.634734 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] File "/var/www/html/flaskapp/flaskapp.wsgi", line 4, in <module>
[Thu Mar 09 18:23:23.634755 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] from flaskapp import app as application
[Thu Mar 09 18:23:23.634762 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] File "/var/www/html/flaskapp/flaskapp.py", line 6, in <module>
[Thu Mar 09 18:23:23.634771 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] import Tools
[Thu Mar 09 18:23:23.634783 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] ImportError: No module named Tools
I'm trying to deploy Flask app via Apache2 but I'm getting No module named app error. I'm also using virtualenv
planer(Flask app)
(venv)jdoe#jdoe-virtual-machine:/var/www/planer$ la
app.py forms.py .git helpers.py __init__.py main.pyc models.pyc README.md setup.cfg templates views.py
app.pyc forms.pyc .gitignore helpers.pyc main.py models.py planer.wsgi requirements.txt static venv views.pyc
planer.conf
<VirtualHost *:80>
ServerName planer.dev
ServerAdmin admin#mywebsite.com
WSGIScriptAlias / /var/www/planer/planer.wsgi
<Directory /var/www/planer/planer/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/planer/static
<Directory /var/www/planer/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
planer.wsgi
import sys, os
sys.path.insert (0,'/var/www/planer')
sys.path = [
'/var/www/planer/venv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
]
activate_this = '/var/www/planer/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import app as application
error
[Wed Jan 06 09:45:29.781102 2016] [:error] [pid 20727] [client 127.0.0.1:42448] mod_wsgi (pid=20727): Target WSGI script '/var/www/planer/planer.wsgi' cannot be loaded as Python module.
[Wed Jan 06 09:45:29.781137 2016] [:error] [pid 20727] [client 127.0.0.1:42448] mod_wsgi (pid=20727): Exception occurred processing WSGI script '/var/www/planer/planer.wsgi'.
[Wed Jan 06 09:45:29.781208 2016] [:error] [pid 20727] [client 127.0.0.1:42448] Traceback (most recent call last):
[Wed Jan 06 09:45:29.781235 2016] [:error] [pid 20727] [client 127.0.0.1:42448] File "/var/www/planer/planer.wsgi", line 12, in <module>
[Wed Jan 06 09:45:29.781302 2016] [:error] [pid 20727] [client 127.0.0.1:42448] import app as application
[Wed Jan 06 09:45:29.781327 2016] [:error] [pid 20727] [client 127.0.0.1:42448] ImportError: No module named app
Make sure the .wsgi file is executable:
sudo chmod a+x planer.wsgi
And try to load it with this:
python /absolute/path/to/planer.wsgi
I have a simple flask app that i want to be accessible from internet.
OS is debian7, and unfortunately it can't be changed.
What I did:
- downloaded and installed Python3.4 into /usr/local/opt/python3.4.3
- installed wsgi lib for py3
- installed virtualenv and created new env in my flask project folder
- installed flask together with some other packages that I need within this env
- created VirtualHost as follows:
cat /etc/apache2/sites-available/Monitor
Listen 8080
<VirtualHost *:8080>
ServerName {ip address}
ServerAdmin {my email}
WSGIScriptAlias / /var/www/Monitor/monitor.wsgi
<Directory /var/www/Monitor/Monitor/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/Monitor/Monitor/static
<Directory /var/www/Monitor/Monitor/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
now when i try to access the app from the internet I see these errors in error.log
[Sat Nov 14 22:16:04 2015] [error] /usr/local/bin/python3
[Sat Nov 14 22:16:04 2015] [error] [client ip] mod_wsgi (pid=13450): Target WSGI script '/var/www/Monitor/monitor.wsgi' cannot be loaded as Python module.
[Sat Nov 14 22:16:04 2015] [error] [client ip] mod_wsgi (pid=13450): Exception occurred processing WSGI script '/var/www/Monitor/monitor.wsgi'.
[Sat Nov 14 22:16:04 2015] [error] [client ip] Traceback (most recent call last):
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/monitor.wsgi", line 21, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from Monitor import app as application
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/__init__.py", line 4, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from flask import Flask, render_template, url_for
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/flask/__init__.py", line 17, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from werkzeug.exceptions import abort
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/werkzeug/__init__.py", line 152, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] __import__('werkzeug.exceptions')
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/werkzeug/exceptions.py", line 113
[Sat Nov 14 22:16:04 2015] [error] [client ip] return u'<p>%s</p>' % escape(self.description)
[Sat Nov 14 22:16:04 2015] [error] [client ip] ^
[Sat Nov 14 22:16:04 2015] [error] [client ip] SyntaxError: invalid syntax
From what I could find in the internet, such errors appear when trying to start flask app with python version <= 3.3, which is not my case I think (how do i check?)
here is my wsgi that starts the app
#!/usr/bin/env python3
import os
import sys
import logging
logging.basicConfig(stream=sys.stderr)
PROJECT_DIR = '/var/www/Monitor/'
sys.path.insert(0, PROJECT_DIR)
def execfile(filename):
globals = dict(__file__ = filename)
exec(open(filename).read(), globals)
activate_this = '/var/www/Monitor/Monitor/venv/bin/activate_this.py'
execfile(activate_this)
from Monitor import app as application
Any help would be very much appreciated. Any additional information will be supplied if necessary.
Default Python3 on Debian 7 is 3.2.3, libapache2-mod-wsgi is in version 3.3.
You Apache run Your app with default Python because mod-wsgi has to be compiled against one and only one python version (in this case python 3.3).
mod-wsgi 3.3
If You want to run only one app (or many apps) with Python 3.4, try to recompile mod-wsgi with python 3.4
mod-wsgi 4.1.x or newer
This newer version of mod_wsgi provides a way of installing mod_wsgi against multiple Python versions and running up an Apache instance for each using a provided script. The script takes over all the setup of the Apache configuration so you do not need to worry about it.
https://pypi.python.org/pypi/mod_wsgi
old answer
To change Python version, set in Apache conf:
WSGIPythonHome /usr/local/opt/python3.4.3/
WSGIPythonPath /var/www/Monitor:/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages:/usr/local/opt/python3.4.3/lib/site-packages
for details read https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonHome
I cannot, for the life of me, find a simple way to configure a (Linode Debian 6) server correctly with Django 1.8, Python 2.7.3, and virtualenv. Here's the steps I took:
mkvirtualenv --python=/usr/bin/python2.7 curator
This creates a VirtualEnv for me under /srv/ve/.virtualenvs/curator
Now I run:
pip install django
And Django 1.8 is successfully installed. Then, I switch to /srv/www/curator and run:
django-admin startproject cmscore
I then follow the Django Apache mod_wsgi instructions and end up with an Apache conf file under my sites-available directory looking like this:
<VirtualHost *:80>
ServerName cms.example.com
ServerAlias cms.example.com cms.example2.com
ServerAdmin errors#example.com
DocumentRoot /srv/www/curator/public_html
WSGIDaemonProcess cms.example.com python-path=/srv/ve/.virtualenvs/curator/bin/python:/srv/ve/.virtualenvs/curator/lib/python2.7/site-packages
WSGIProcessGroup cms.example.com
WSGIScriptAlias / /srv/www/curator/cmscore/cmscore/wsgi.py
<Directory /srv/www/curator/cmscore/cmscore>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Alias /robots.txt /srv/www/curator/public_html/robots.txt
Alias /favicon.ico /srv/www/curator/public_html/favicon.ico
Alias /css /srv/www/curator/public_html/css
Alias /js /srv/www/curator/public_html/js
Alias /img /srv/www/curator/public_html/img
Alias /static/admin /srv/www/curator/public_html/admin
Alias /static /srv/www/curator/public_html/static
Alias /media /srv/www/curator/public_html/media
ErrorLog /srv/www/curator/logs/error.log
CustomLog /srv/www/curator/logs/access.log combined
</VirtualHost>
The Django docs mention an WSGIPythonPath directive, but I get an error that WSGIPythonPath cannot occur within <VirtualHost> section when I use this.
With this configuration I get a 500 error (well obviously, there's a lot of settings I haven't added yet for example) but not one that I would expect. I get this (IPs blanked by me):
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] mod_wsgi (pid=21802): Target WSGI script '/srv/www/curator/cmscore/cmscore/wsgi.py' cannot be loaded as Python module.
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] mod_wsgi (pid=21802): Exception occurred processing WSGI script '/srv/www/curator/cmscore/cmscore/wsgi.py'.
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] Traceback (most recent call last):
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] File "/srv/www/curator/cmscore/cmscore/wsgi.py", line 15, in <module>
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] from django.core.wsgi import get_wsgi_application
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] File "/srv/ve/.virtualenvs/curator/lib/python2.7/site-packages/django/__init__.py", line 1, in <module>
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] from django.utils.version import get_version
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] File "/srv/ve/.virtualenvs/curator/lib/python2.7/site-packages/django/utils/version.py", line 7, in <module>
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] from django.utils.lru_cache import lru_cache
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] File "/srv/ve/.virtualenvs/curator/lib/python2.7/site-packages/django/utils/lru_cache.py", line 28
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] fasttypes = {int, str, frozenset, type(None)},
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] ^
[Thu May 21 14:55:16 2015] [error] [client xxx.xxx.xxx.xxx] SyntaxError: invalid syntax
So, this appears to be an error which occurs when Django 1.8 is being using by an earlier version of Python than 2.7. To debug, I threw this into the top of my wsgi.py file:
import sys
activate_this = '/srv/ve/.virtualenvs/curator/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.stderr.write(sys.version)
And in my Apache error log, I see:
2.6.6 (r266:84292, Dec 27 2010, 00:18:12)
I've tried every trick that I can think of (tricks that worked with existing virtualenvs of Django 1.6 and Python 2.7 on the exact same server!) including shebangs pointing to the correct Python install in my manage.py file, but I cannot find any way to get this to work.
I know I'm missing something really obvious here, but I am blind to it, can anyone help?