On Jan 3, 5:28 pm, Michael Pedersen <[email protected]> wrote:
> Actually, your problem is very simple to understand: You are running the
> system's python from Apache, but you are running your virtualenv's python
> from the command line.
>
> The result is exactly what you're seeing: Apache can't import the necessary
> files, because they're not in the system's python path.
>
> The fix, though, is actually fairly easy: In your Apache config file, you
> need to set up a variable named WSGIPythonHome.

Sorry, using WSGIPythonHome is not necessary, using site.addsitedir()
to add a virtual environment is sufficient. Read:

  http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

There problem is more likely that since Apache runs as a special user
and not the user of the OP, it likely doesn't have read/search
permissions on files/directories.

Graham

> If you have configured
> things such that mod_wsgi is loaded from its own config file, it's best to
> set it there.Based on what you've shown above, you will want this line
> somewhere in your apache configuration, after mod_wsgi is loaded:
>
> WSGIPythonHome /home/tgdev/spacetime
>
> Note: The above is based on my Debian system, latest stable, running Apache
> 2.2.9 with mod_wsgi 2.5-1~lenny1 as the package versions. The system is
> running TurboGears 2.0 (haven't upgraded to the 2.1 packages yet). If your
> version differ significantly, you may need a different variable, or possibly
> a different path. Also, I have not checked over the remainder of your
> configuration, and there may be other issues. This, though, should at least
> get you going.
>
>
>
> On Sat, Jan 2, 2010 at 10:19 PM, Todd Blanchard <[email protected]> wrote:
> > Thanks, I've had a look at that.  Its the same - when apache runs the wsgi
> > file, the import fails.  When I run it from the command line, it works OK.
> >  I'm really frustrated - been working on this deployment for two days and it
> > has been problem after problem with postgis, apache, python, turbogears.....
>
> > It really shouldn't be this hard to build a deployment.
>
> > On Jan 2, 2010, at 6:17 PM, Lukasz Szybalski wrote:
>
> > > On Sat, Jan 2, 2010 at 6:23 PM, Todd Blanchard <[email protected]>
> > wrote:
> > >> I've been trying for a couple days to get a production server deployed
> > using centos 5.3, apache 2.4, postgres, and TG2.1a3.
>
> > >> I'm stuck.  HELP!
>
> > >> The error in the apache log is:
>
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215] mod_wsgi
> > (pid=6103): Target WSGI script '/var/www/wsgi-scripts/eagle.wsgi' cannot be
> > loaded as Python module.
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215] mod_wsgi
> > (pid=6103): Exception occurred processing WSGI script
> > '/var/www/wsgi-scripts/eagle.wsgi'.
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215] Traceback
> > (most recent call last):
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215]   File
> > "/var/www/wsgi-scripts/eagle.wsgi", line 8, in <module>
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215]     from
> > paste.deploy import loadapp
> > >> [Sun Jan 03 00:02:34 2010] [error] [client 71.227.129.215] ImportError:
> > No module named paste.deploy
>
> > >> The script file (which is using a virgin python 2.6 installed +
> > virtualenv is:
>
> > >> import os, sys
>
> > >> APP_NAME = 'eagle'
> > >> ENV_PATH = '/home/tgdev/spacetime'
> > >> APP_PATH = ENV_PATH + '/eagle'
> > >> PKG_PATH = ENV_PATH + '/lib/python2.6/site-packages'
>
> > >> import site
> > >> site.addsitedir(PKG_PATH)
> > >> site.addsitedir(APP_PATH)
> > >> os.environ['PYTHON_EGG_CACHE'] = '/var/tmp/python-eggs/'+APP_NAME
>
> > >> from paste.deploy import loadapp
>
> > >> application = loadapp('config:' + APP_PATH + '/development.ini')
>
> > >> The resulting sys.path I get when running it from the command line with
> > the call to loadapp replaced by print sys.path is:
>
> > >> /var/www/wsgi-scripts
> > >> /opt/python2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.e 
> > gg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/pip-0.6.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/tg.devtools-2.1a3-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.who-1.0.18-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.what_quickstart-1. 
> > 0.3_r6729-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.eg 
> > g
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/sqlalchemy_migrate-0.5.4- 
> > py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/TurboGears2-2.1a3-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/zope.interface-3.5.2-py2. 
> > 6-linux-x86_64.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.who_friendlyform-1 
> > .0b3-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.what.plugins.sql-1 
> > .0rc3_r6698-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.who.plugins.sa-1.0 
> > rc2-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.what-1.0.8-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/decorator-3.0.0-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.tm2-1.0a5-py2.6.eg 
> > g
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.what_pylons-1.0-py 
> > 2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebError-0.10.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/ToscaWidgets-0.9.8-py2.6. 
> > egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebFlash-0.1a9-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/Genshi-0.5.1-py2.6-linux- 
> > x86_64.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.who_testutil-1.0rc 
> > 1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/transaction-1.0.0-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/simplejson-2.0.9-py2.6-li 
> > nux-x86_64.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/Pygments-1.1.1-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Tempita-0.4-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebOb-0.9.6.1-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/WebTest-1.1-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Mako-0.2.5-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/nose-0.11.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/FormEncode-1.2.2-py2.6.eg 
> > g
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/PasteDeploy-1.3.3-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebHelpers-0.6.4-py2.6.eg 
> > g
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/Routes-1.10.3-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Beaker-1.5.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.geo-0.6-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/TileCache-2.10-py2.6.egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/mapfish-1.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/psycopg2-2.0.13-py2.6-lin 
> > ux-x86_64.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/GeoAlchemy-0.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/FeatureServer-1.12-py2.6. 
> > egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.admin-0.3.6-py2.6.e 
> > gg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/zope.sqlalchemy-0.4-py2.6 
> > .egg
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/Babel-0.9.4-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.crud-0.3.3-py2.6.eg 
> > g
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages/sprox-0.6.6-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/geojson-1.0.1-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/Shapely-1.0.14-py2.6.egg
>
> > /home/tgdev/spacetime/lib/python2.6/site-packages/tw.forms-0.9.8-py2.6.egg
> > >> /home/tgdev/spacetime/eagle
> > >> /opt/python2.6/lib/python2.6/site-packages/virtualenv-1.4.3-py2.6.egg
> > >> /opt/python2.6/lib/python26.zip
> > >> /opt/python2.6/lib/python2.6
> > >> /opt/python2.6/lib/python2.6/plat-linux2
> > >> /opt/python2.6/lib/python2.6/lib-tk
> > >> /opt/python2.6/lib/python2.6/lib-old
> > >> /opt/python2.6/lib/python2.6/lib-dynload
> > >> /opt/python2.6/lib/python2.6/site-packages
> > >> /home/tgdev/spacetime/lib/python2.6/site-packages
>
> > >> My virtual host config is:
>
> > >> <VirtualHost *:80>
>
> > >>    ServerName **************
> > >>    ServerAlias ***************
> > >>    ServerAdmin [email protected]
>
> > >>    <Directory /var/www/static/eagle>
> > >>    Options Indexes FollowSymLinks
> > >>    AllowOverride None
> > >>    Order allow,deny
> > >>    Allow from all
> > >>    </Directory>
>
> > >>    DocumentRoot /var/www/static/eagle
>
> > >>    Alias /robots.txt /var/www/static/eagle/robots.txt
> > >>    Alias /favicon.ico /var/www/static/eagle/favicon.ico
> > >>    Alias /css/ /var/www/static/eagle/css/
> > >>    Alias /images/ /var/www/static/eagle/images/
> > >>    Alias /media/ /var/www/static/eagle/media/
>
> > >>    #WSGIDaemonProcess eagleoffshore.biz processes=2 threads=15
> > display-name=%{GROUP}
> > >>    #WSGIProcessGroup eagleoffshore.biz
>
> > >>    WSGIScriptAlias / /var/www/wsgi-scripts/eagle.wsgi
>
> > >>    <Directory /var/www/wsgi-scripts>
> > >>    Order allow,deny
> > >>    Allow from all
> > >>    </Directory>
>
> > >> </VirtualHost>
>
> > > I would try modwsgideploy to help with the setup....
> > >http://turbogears.org/2.0/docs/main/Deployment/modwsgi+virtualenv.html
>
> > > Lucas
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > "TurboGears" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > [email protected]<turbogears%2bunsubscr...@googlegrou 
> > ps.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/turbogears?hl=en.
>
> > --
>
> > You received this message because...
>
> read more »

--

You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.


Reply via email to