On 14 April 2011 00:13, Paddy Joy <[email protected]> wrote:
> Hi,
>
> I have attempted to set up a virtualenv to run some applications using
> django 1.2.5. From the command line everything appears to be ok
> however when I run the application using mod_wsgi daemon mode I am
> getting conflicting versions of site-packages in sys.path.
Have you tried using --no-site-packages to virtualenv, or do you still
want fallback to base Python installation?
Anyway, see real reason for problem below.
> Config:
>
> Django 1.25 in /usr/local/pythonenv/DJANGO_LEGACY_1.2/lib/python2.5/
> site-packages/django
> Django svn in /usr/lib/python2.5/site-packages/django
>
> django.wsgi
>
> import os, sys, site
>
> site.addsitedir('/usr/local/pythonenv/DJANGO_LEGACY_1.2/lib/python2.5/
> site-packages')
You have this in the wrong spot. See:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
You are meant to save away sys.path before calling site.addsitedir().
> prev_sys_path = list(sys.path)
>
> sys.path.append('/var/django')
> sys.path.append('/var/django/fasttraku')
> sys.path.append('/var/django/debug_toolbar')
>
>
> 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
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'fasttraku.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> print sys.path
>
> The output of print.sys shows:
> ['/usr/local/pythonenv/DJANGO_LEGACY_1.2/lib/python2.5/site-
> packages', ........... '/usr/lib/python2.5/site-packages']
>
> When operating from the command line the virtualenv sys.path doesn't
> include '/usr/lib/python2.5/site-packages' and everything works as
> expected but when running through the mod_wsgi daemon both paths are
> included which causes the wrong versions of packages to be imported.
>
> Any ideas what I am doing wrong?
>
> Paddy
>
> --
> 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.
>
>
--
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.