1

So, similar to this question, I can't seem to get Pyramid and mod_wsgi agree enough to host my application.

Here's my virtualhost

LoadModule proxy_module modules/mod_proxy.so
WSGIPythonHome /usr/local/pythonenv/BASELINE
WSGIPythonPath /usr/local/pythonenv/BASELINE

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName domain.com
  ServerAdmin me@domain.com

  ErrorLog /home/me/log/error.log
  CustomLog /home/me/log/access.log combined

  WSGIApplicationGroup %{GLOBAL}
  WSGIPassAuthorization On

  WSGIDaemonProcess pyramid user=www-data group=www-data \
      processes=1 threads=4 \
      python-path=/var/app/app/appenv/lib/python2.7/site-packages
  WSGIScriptAlias / /var/app/app/dispatch.wsgi

  <Directory /var/app/app/>
  WSGIProcessGroup pyramid
  Order allow,deny
  Allow from all
  </Directory>
</VirtualHost>

My dispatch.wsgi looks like this:

activate_this = '/var/app/app/appenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import os
os.environ['PYTHON_EGG_CACHE'] = '/var/app/app/dist'

# Load the Pylons application
from pyramid.paster import get_app, setup_logging
ini_path = '/var/app/app/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')

I even get the same error:

[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx] mod_wsgi (pid=8156): Target WSGI script '/var/app/app/dispatch.wsgi' cannot be loaded as Python module.
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx] mod_wsgi (pid=8156): Exception occurred processing WSGI script '/var/app/app/dispatch.wsgi'.
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx] Traceback (most recent call last):
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx]   File "/var/app/app/dispatch.wsgi", line 9, in <module>
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx]     from pyramid.paster import get_app, setup_logging
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx]   File "/usr/local/lib/python2.7/dist-packages/pyramid/paster.py", line 3, in <module>
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx]     from paste.deploy import (
[Tue May 06 11:45:54 2014] [error] [client xxx.xx.xx.xxx] ImportError: No module named paste.deploy

Permissions should be fine too:

-rwxr-xr-x 1 me me  458 May  5 14:42 dispatch.wsgi

From the fact that Pyramid's trying to use the paster in /usr/local/lib it seems to me that for some reason it's just not picking up on the virtualenv specific to my application. Any ideas?

It's worth noting that there's another mod_wsgi application running on the server not in daemon mode. Could that be interfering?

Community
  • 1
  • 1
pjc
  • 127
  • 1
  • 11
  • yes, it could be interfering. You should use daemon mode if you want multiple unrelated processes (full disclosure - I've never used Pylons, only Django, though I think as far as deployment goes it's similar) – yuvi May 06 '14 at 16:21
  • Moving the other app to daemon mode didn't seem to work. Any other thoughts? – pjc May 06 '14 at 18:09
  • Well, the WSGIPythonHome is the directive that is supposed to point at your alternative python environment (i.e your project's virtualenv), so I'll look for [other people who had problems with it](http://stackoverflow.com/questions/8660896/mod-wsgi-isnt-honoring-wsgipythonhome). Besides that, I'd suggest you try and remove the other app from apache temporarily, just to completely rule out that that is the problem. – yuvi May 06 '14 at 21:04
  • Also - is it possible that the other app is using a *different version* of python? (for example, if one app uses python 2.7 and the other uses 3.3, this might cause problems with an incompatible mod_wsgi) – yuvi May 06 '14 at 21:08
  • 2
    What version of virtualenv are you using and if it is a recent version, did you use the --site-packages option (not recommended). If the virtualenv is setup to be isolated from the main site-packages, it should not be picking up stuff from /usr/local/lib/python2.7/dist-packages. Also, are you loading mod_python into the same Apache. Answer those questions first and then will point out other problems in your setup. – Graham Dumpleton May 06 '14 at 23:29
  • @GrahamDumpleton -- virtualenv is version 1.7.1.2. I used --system-site-packages, and very suddenly I see why this may have been a problem. Also, it doesn't look like we're using mod_python. – pjc May 08 '14 at 17:05
  • @yuvi They're both running 2.7 and they're both now in daemon mode. I unfortunately cannot turn the other project off. – pjc May 08 '14 at 17:07
  • 1
    The next problem was that 'WSGIPythonPath /usr/local/pythonenv/BASELINE' is likely wrong. That doesn't take the sys.prefix value of a Python installation but a directory containing Python modules. Would have done no harm, but likely wouldn't have done anything either. – Graham Dumpleton May 09 '14 at 03:28

0 Answers0