Thursday, June 30, 2011

Installing requirements in a virtualenv works when installed manually, fails when installed automatically

Hi,


i've encountered a strange problem. When I install packages on the server in a virtualenv
with pip manually, my page loads correctly.
If I install the requirements via "pip install -r requirements", then i get the following error in apache:

Internal Server Error

Apaches error.log:
[Thu Jun 30 15:04:27 2011] [info] [client 172.16.50.2] mod_wsgi (pid=5416, process='', application='inventory|'): Loading WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi'.
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] mod_wsgi (pid=5416): Target WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi' cannot be loaded as Python module.
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] mod_wsgi (pid=5416): Exception occurred processing WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi'.
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] Traceback (most recent call last):
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] File "/home/ict/websites/inventory/inventory/apache/inventory.wsgi", line 27, in
<module>
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] import django.core.handlers.wsgi
[Thu Jun 30 15:04:27 2011] [error] [client 172.16.50.2] ImportError: No module named django.core.handlers.wsgi
[Thu Jun 30 15:04:27 2011] [debug] mod_deflate.c(615): [client 172.16.50.2] Zlib: Compressed 605 to 372 : URL /
[Thu Jun 30 15:04:30 2011] [info] [client 172.16.50.2] mod_wsgi (pid=5417, process='', application='inventory|'): Loading WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi'.
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] mod_wsgi (pid=5417): Target WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi' cannot be loaded as Python module.
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] mod_wsgi (pid=5417): Exception occurred processing WSGI script
'/home/ict/websites/inventory/inventory/apache/inventory.wsgi'.
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] Traceback (most recent call last):
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] File "/home/ict/websites/inventory/inventory/apache/inventory.wsgi", line 27, in
<module>
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] import django.core.handlers.wsgi
[Thu Jun 30 15:04:30 2011] [error] [client 172.16.50.2] ImportError: No module named django.core.handlers.wsgi
[Thu Jun 30 15:04:30 2011] [debug] mod_deflate.c(615): [client 172.16.50.2] Zlib: Compressed 605 to 372 : URL /

The inventory.wsgi file:
=====================================
import sys
import os

apache_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.normpath(os.path.join(apache_dir + '/../..'))
app_dir = os.path.normpath(os.path.join(apache_dir + '/..'))

sys.path = [
os.path.join(project_dir, 'lib/python2.7/site-packages'),
project_dir,
app_dir
] + sys.path

os.environ['DJANGO_SETTINGS_MODULE'] = 'inventory.settings'

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

There is nothing wrong with apache/nginx/memcached as other projects run correctly.

Although I have a solution, I'm puzzled as to what causes this.
My requirements file:

-e svn+http://code.djangoproject.com/svn/django/trunk#egg=django
Werkzeug==0.6.2
-e
git+git://kwebvs02/projects/common_utils#egg=common_utils
distribute==0.6.14
django-extensions==0.6
psycopg2==2.4.2
python-memcached==1.47
wsgiref==0.1.2

I use Django from trunk, common_utils is a local lib I developed .
So using above requirements, installation with pip -r fails, installing them manually works, for instance
pip install psycopg2

Any idea?

Cheers,
Benedict

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment