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

33 views
Skip to first unread message

Benedict Verheyen

unread,
Jun 30, 2011, 10:59:45 AM6/30/11
to django...@googlegroups.com
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

Tom Evans

unread,
Jun 30, 2011, 11:27:42 AM6/30/11
to django...@googlegroups.com
On Thu, Jun 30, 2011 at 3:59 PM, Benedict Verheyen
<benedict...@gmail.com> wrote:
> 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:
>

Did you forget to tell pip to install to a virtualenv? Activate the
virtualenv, or pass "-E /path/to/venv/base" to pip.

If that doesn't work, we'd probably need to see the pip installation log.

Cheers

Tom

Reply all
Reply to author
Forward
0 new messages