2009/7/3 Friðrik Már Jónsson <[email protected]>:
>
> Hi folks,
>
> I'm trying to configure my mod_wsgi 2.5 to allow virtual Python
> environments, as described on the wiki[1].
>
> I decided to go with a Python baseline, so I took the following steps:
>
>  1. created a virtual environment at /usr/local/baseline (with --no-
> site-packages)
>  2. placed `WSGIPythonHome /usr/local/baseline` at the bottom of my
> apache2.conf file[2]
>  3. restarted Apache
>  4. attempted to load the page and import the `django` module
>  5. loading the module was rather too successful for the empty
> baseline environment, and at restart I got:
>
>  [Fri Jul 03 12:08:11 2009] [warn] mod_wsgi: Python module path '/usr/
> lib/python2.5/:/usr/lib/python2.5/plat-linux2:/usr/lib/python2.5/lib-
> tk:/usr/lib/python2.5/lib-dynload'.

What are the few lines before this though. They are more important and
dumping out the module path at this point isn't even done in mod_wsgi
3.0 any more as it is basically meaningless.

> Here's where the problem exists.  I'm successful in importing the
> django module that's installed on the system's main Python
> configuration.  My understanding was that defining a `WSGIPythonHome`
> would override the system's Python and make all packages installed
> there unavailable.
>
> I modified the WSGI file that was being called to return an exception
> with the Django version and the current sys.path, which I could then
> view in the Apache log:

For how to log stuff rather than using exceptions, read:

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

>  Exception: ((1, 0, 2, 'final', 0), ['/usr/lib/python2.5/site-
> packages/pip-0.3dev-py2.5.egg', '/usr/lib/python2.5/site-packages/
> virtualenv-1.3.2-py2.5.egg', '/usr/lib/python2.5/site-packages/
> virtualenvwrapper-1.8.1-py2.5.egg', '/usr/lib/python2.5/site-packages/
> Trac-0.11.4-py2.5.egg', '/usr/lib/python2.5/site-packages/Genshi-0.5.1-
> py2.5-linux-i686.egg', '/usr/lib/python2.5/site-packages/
> TracMercurial-0.11.0.7-py2.5.egg', '/usr/lib/python2.5/site-packages/
> agilo-0.7.4.1_r1624_20090611-py2.5.egg', '/usr/lib/python2.5/site-
> packages/ReviewBoard-1.0-py2.5.egg', '/usr/lib/python2.5/site-packages/
> pytz-2009j-py2.5.egg', '/usr/lib/python2.5/site-packages/
> flup-1.0.3.dev_20090612-py2.5.egg', '/usr/lib/python2.5/site-packages/
> Pygments-1.0-py2.5.egg', '/usr/lib/python2.5/site-packages/Djblets-0.5-
> py2.5.egg', '/usr/lib/python2.5/site-packages/django_evolution-0.0.0-
> py2.5.egg', '/usr/lib/python2.5/site-packages/Django-1.0.2_final-
> py2.5.egg', '/usr/lib/python2.5/site-packages/PIL-1.1.6-py2.5-linux-
> i686.egg', '/usr/lib/python2.5/site-packages/TracWysiwyg-0.2_r5931-
> py2.5.egg', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/
> usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/
> local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-
> packages', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/
> site-packages'])

Does /usr/local/baseline/lib/python2.5/site-packages exist and what is in it?

> So there I've placed my virtual environment as Python home, but `/usr/
> lib/python2.5/` is still being used.
>
> I wanted to make sure `www-data` had access to this directory, so I
> tried:
>
>  frid...@encom:/etc/apache2/mods-enabled$ sudo su www-data
>  sh-3.2$ source /usr/local/baseline/bin/activate
>  (baseline)sh-3.2$
>
> I don't seem to have any means of debugging what's happening or not
> happing with the `WSGIPythonHome` directive when it's interpreted,
> because it seems that whatever path I put there (however valid), it
> doesn't log a single thing even in `LogLevel debug` mode.

If you can compile mod_wsgi 3.0 from subversion trunk it should dump
out value of WSGIPythonHome if set and used when mod_wsgi initialises
Python.

> `mod_python` is not enabled (it was mentioned that it would interfere
> with WSGIPythonHome, making it ineffective), this is my `mods-enabled`
> folder: alias.conf, alias.load, auth_basic.load, authn_file.load,
> authz_default.load, authz_groupfile.load, authz_host.load,
> authz_user.load, autoindex.conf, autoindex.load, cgid.conf, cgid.load,
> deflate.conf, deflate.load, dir.conf, dir.load, env.load, mime.conf,
> mime.load, negotiation.conf, negotiation.load, setenvif.conf,
> setenvif.load, status.conf, status.load, wsgi.conf, wsgi.load
>
> I'd appreciate any suggestions that could help troubleshoot this,
> Friðrik Már
>
> [1] http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
> [2] This is used in the Debian Apache hierarchy, and is essentially
> the main config file, equal to httpd.conf in some distributions. At
> any rate, this is loaded before any WSGIScriptAlias call.

Can you post the actual Apache configuration snippets you are using
related to mod_wsgi. I also want to see how you might then be using
WSGIPythonPath or python-path option to WSGIDaemonProcess and even
whether you are using daemon mode or embedded mode. Plus how you might
be using sys.path or site.addsitedir in the WSGI script file, so post
the WSGI script file as well. Also have your WSGI script dump out the
value of os.environ['PYTHONPATH']. I want to make sure that the way
you are starting Apache isn't causing that to be inherited from
somewhere.

I am about to sleep for the night, so will be tomorrow before can look
at any response.

Graham

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" 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/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to