Trying to change the Pylons version my website is using but this causes a DistributionNotFound exception
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 no开发者_如何学运维w 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?
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.
精彩评论