1

I'm trying to deploy a django app with virtualenv but I'm not a linux expert user.

It's on a shared host. If I type python I got the python 2.4 console. If a type python2.7 I got the 2.7 console.

I want to use the 2.7.

  1. I installed virtualenv with setuptools in my private .site-packages.
  2. I created my env using python 2.7: .site-packages/virtualenv --no-site-packages -p python2.7 env
  3. I activated my env and installed the packages I need.
  4. I configured (tried to) my .wsgi to use the env

I've been 2 days in step 4. The server has some pre installed modules, which are on sys.path. For example, it has django installed, but I want to use the module installed in my virtualenv.

I read several wsgi documentation and I came to this:

import sys, os, site

sys.stdout = sys.stderr

os.environ['PYTHON_EGG_CACHE'] = '/home/bruddennautica/apps_wsgi/.python-eggs'
os.environ['DJANGO_SETTINGS_MODULE'] = "brudden.settings"

sys.path.append('/home/bruddennautica/apps_wsgi')
sys.path.append('/home/bruddennautica/apps_wsgi/env/lib/python2.7/site-packages')

activate_this = '/home/bruddennautica/apps_wsgi/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

With this conf, I got a django error which shows me some things. The django error isn't important, it's caused because the django version is not equal to the one I installed in my virtualenv, the python version either.

PRINT: http://dl.dropbox.com/u/9290581/error.png

It's possible to see the python path entries, most of them not from virtualenv. The first one is: /home/bruddennautica/apps_wsgi/env/lib/python2.4/site-packages. However this folder doesn't exists. Apparently it's added by activate_this.py in line 22:

site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')

Anyone can help me?

Thanks

3
  • Your screenshot omits the most important part of the error message. Please show the top of the error message. Commented May 15, 2012 at 19:32
  • As i said. The error is not important. It's because its running the django 1.3 installed by host, and not the 1.4 installed in my env. Commented May 15, 2012 at 19:36
  • It doesn't look like your virtualenv is being activated - your error message refers to /usr/bin/python throughout (see Python executable at the top). Also, please post your error messages either here, or as a text document somewhere so copy/paste works. Commented May 15, 2012 at 21:45

1 Answer 1

1

If your mod_wsgi is compiled for Python 2.4, you cannot use Python 2.7. You cannot even point mod_wsgi at a virtual environment constructed using Python 2.7. The only choice you have is to installed a mod_wsgi compiled against mod_wsgi, either from a binary distro package if available, or by compiling mod_wsgi from source code your self against the correct Python version.

Right now it seems you may be mixing Python versions, which you cannot do and will cause errors including crashes. You need to find out what version of Python mod_wsgi was compiled for.

See:

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library

for one way of finding this out.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Graham. I don't think I can install my own mod_wsgi, it's in a shared host. I'll have to content myself with python 2.4. I couldn't find in what version of python mod_wsgi was compiled either. I don't have access to mod_wsgi.so. Thanks for replies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.