Good morning,
I did the reordering procedures of the sys.path variable.
Here is the mod_wsgi configuration in Apache. There is two pylons
application that I want to run, each with its own python virtualenv.
All the permissions of the virtualenv directories are OK (I can load
everything with another username).
I also tried changing the baseline environemnt, without succes
(WSGIPythonHome).
################### httpd.conf ###################
# Site de Louis-Philippe
<Directory /home/lemieulp/Public/Louis_HomePage/mod_wsgi>
Order deny,allow
Allow from all
</Directory>
NameVirtualHost *:8080
<VirtualHost *:8080>
# Site de Louis-Philippe
WSGIScriptAlias /lemieulp /home/lemieulp/Public/Louis_HomePage/
mod_wsgi/dispatch.wsgi
# # Site de Francois
# WSGIScriptAlias /francois /home/francois/MyBlog/apache/
myblog.wsgi
</VirtualHost>
################### httpd.conf ############# END #
And here is the WSGI script file in question.
################### dispatch.wsgi ###################
ALLDIRS = ['/home/lemieulp/python_virtualenv/lib/python2.6/site-
packages']
import sys
import site
# Original sys.path
prev_sys_path = list(sys.path)
# Add site-packages
for directory in ALLDIRS:
site.addsitedir(directory)
# Reorder sys.path
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
# Avoird ``[Errno 13] Permission denied: '/var/www/.python-egg'``
messages
import os
sys.path.append('/home/lemieulp/Public/Louis_HomePage')
os.environ['PYTHON_EGG_CACHE'] = '/home/lemieulp/Public/Louis_HomePage/
egg-cache'
# Load the Pylons application
from paste.deploy import loadapp
application = loadapp('config:/home/lemieulp/Public/Louis_HomePage/
development.ini')
################### dispatch.wsgi ############# END #
Here is the error log of Apache (with LogLevel set to debug).
################### Apache error_log ###################
[Tue Feb 09 09:03:23 2010] [info] mod_wsgi (pid=17449): Create
interpreter '::1:8080|/lemieulp'.
[Tue Feb 09 09:03:23 2010] [info] [client ::1] mod_wsgi (pid=17449,
process='', application='::1:8080|/lemieulp'): Loading WSGI script '/
home/lemieulp/Public/Louis_HomePage/mod_wsgi/dispatch.wsgi'.
[Tue Feb 09 09:03:23 2010] [error] [client ::1] mod_wsgi (pid=17449):
Target WSGI script '/home/lemieulp/Public/Louis_HomePage/mod_wsgi/
dispatch.wsgi' cannot be loaded as Python module.
[Tue Feb 09 09:03:23 2010] [error] [client ::1] mod_wsgi (pid=17449):
Exception occurred processing WSGI script '/home/lemieulp/Public/
Louis_HomePage/mod_wsgi/dispatch.wsgi'.
[Tue Feb 09 09:03:23 2010] [error] [client ::1] Traceback (most recent
call last):
[Tue Feb 09 09:03:23 2010] [error] [client ::1] File "/home/lemieulp/
Public/Louis_HomePage/mod_wsgi/dispatch.wsgi", line 27, in <module>
[Tue Feb 09 09:03:23 2010] [error] [client ::1] from paste.deploy
import loadapp
[Tue Feb 09 09:03:23 2010] [error] [client ::1] ImportError: No module
named deploy
################### Apache error_log ############# END #
Thank you!
On Feb 8, 11:27 pm, Graham Dumpleton <[email protected]>
wrote:
> On 9 February 2010 14:16, louisplp <[email protected]> wrote:
>
> > Yes, I use site.addsitedir. But it still loads the paste package of
> > the system python.
>
> > $ python
> >>>> import site
> >>>> site.addsitedir('/home/lemieulp/python_virtualenv/lib/python2.6/site-packages')
> >>>> import paste
> >>>> print paste.__path__
> > ['/usr/lib/python2.6/site-packages/paste']
>
> That is because site.addsitedir() sticks stuff at the end of sys.path
> and doesn't reorder the path to put new additions at front and so
> before anything that may be installed in site wide Python. Have a read
> of:
>
> http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
>
> where it talks about reordering and what you need to manually do
> and/or how to avoid that by using python-path option or WSGIPythonPath
> directive as appropriate.
>
> Can you post more about the mod_wsgi configuration in Apache you are
> using and what you have in the WSGI script file?
>
> Graham
>
> > Here is what I have when using the virtualenv I created
>
> > $ ~/python_virtualenv/bin/python
> >>>> import paste
> >>>> print paste.__path__
> > ['/home/lemieulp/python_virtualenv/lib/python2.6/site-packages/
> > PasteScript-1.7.3-py2.6.egg/paste', '/home/lemieulp/python_virtualenv/
> > lib/python2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste', '/home/
> > lemieulp/python_virtualenv/lib/python2.6/site-packages/Paste-1.7.2-
> > py2.6.egg/paste']
>
> > Yes, the .pth file (which is easy-install.pth) contains the required
> > namespace
>
> > $ cat easy-install.pth
> > import sys; sys.__plen = len(sys.path)
> > ./setuptools-0.6c11-py2.6.egg
> > ./pip-0.6.3-py2.6.egg
> > ./Pylons-0.9.7-py2.6.egg
> > ./Tempita-0.4-py2.6.egg
> > ./WebTest-1.2-py2.6.egg
> > ./WebError-0.10.1-py2.6.egg
> > ./WebOb-0.9.8-py2.6.egg
> > ./Mako-0.2.5-py2.6.egg
> > ./nose-0.11.1-py2.6.egg
> > ./decorator-3.1.2-py2.6.egg
> > ./simplejson-2.0.9-py2.6-linux-i686.egg
> > ./FormEncode-1.2.2-py2.6.egg
> > ./PasteScript-1.7.3-py2.6.egg
> > ./PasteDeploy-1.3.3-py2.6.egg
> > ./Paste-1.7.2-py2.6.egg
> > ./Beaker-1.5.1-py2.6.egg
> > ./WebHelpers-1.0b4-py2.6.egg
> > ./Routes-1.11-py2.6.egg
> > ./Pygments-1.2.2-py2.6.egg
> > ./Sphinx-0.6.4-py2.6.egg
> > ./docutils-0.6-py2.6.egg
> > ./Jinja2-2.2.1-py2.6.egg
> > ./AuthKit-0.4.5-py2.6.egg
> > ./elementtree-1.2.7_20070827_preview-py2.6.egg
> > ./python_openid-2.2.4-py2.6.egg
> > import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
> > p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p
> > +len(new)
>
> > On 8 fév, 22:03, Ian Bicking <[email protected]> wrote:
> >> On Mon, Feb 8, 2010 at 8:43 PM, Graham Dumpleton
> >> <[email protected]
>
> >> > wrote:
> >> > python
> >> > >>> import paste
> >> > >>> print paste.__file__
>
> >> > That will give you location.
>
> >> It gets more complicated; since paste is a namespace package then
> >> paste.__path__ may contain other paths that will be searched, e.g.,
> >> site-packages/Paste-X.Y.egg/paste and
> >> site-packages/PasteDeploy-X.Y.egg/paste -- or, if it's not working, maybe
> >> those values won't be right.
>
> >> Though of course it should work properly, you might try pip which installs
> >> namespace packages flat, and might at least avoid the problem you are
> >> having.
>
> >> Also if you aren't using site.addsitedir, you might not get the path setup
> >> properly; there's a .pth file which I believe makes sure easy_install'd
> >> namespace packages work.
>
> >> --
> >> Ian Bicking | http://blog.ianbicking.org | http://twitter.com/ianbicking
>
> > --
> > 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
> > athttp://groups.google.com/group/modwsgi?hl=en.
--
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.