views:

17

answers:

1

About a month ago I setup Pylons on my VPS in a virtual environment using the go-pylons.py script they provide. I've, since then, been working on my website and have it all up and running. It works great.

Recently though I discovered that I created my virtual python environment using Python2.5. I now want to change this to Python2.7

I've got Python2.7 running on my server and it all works great. I then created another virtual environment for Pylons and have that up and running. When I try to modify my website's mod_wsgi dispatch file to use the new environment, I get a DistributionNotFound exception. What could be causing this?

Here's my dispatch.wsgi file:

import site
import os

# New Python virtual environment
# site.addsitedir('/usr/local/pylonsenv/lib/python2.7/site-packages')

# Old Python virtual environment
site.addsitedir('/usr/local/pylons/lib/python2.5/site-packages')
os.environ['PYTHON_EGG_CACHE'] = '/home/samsu/python/egg-cache'

from paste.deploy import loadapp
application = loadapp('config:/home/samsu/python/mywebsite/production.ini')

When I change the addsitedir paths around and restart Apache, viewing the website throws the exception. As soon as I change it back, problem goes away.

Why can't I change virtual environments?

+1  A: 

For starters, you must recompile/reinstall mod_wsgi against Python 2.7, you cannot just point it at a new virtual environment using a newer Python version. Likely that the older Python installation doesn't have new enough version of a package required by code installed into your Python 2.7 virtual environment.

Graham Dumpleton
From memory, I did recompile mod_wsgi to use Python2.7 when I installed Python. Having said that, I've given up and decided to use nginx as a proxy to Paster. I hear nginx is pretty good with performance... Hopefully the same goes for Paster. I'll continue my research on that now!
samsu