katie bekell
katie bekell

Reputation: 361

Django Import Error using EC2 and bitnami

I am trying to deploy my django app to amazon's ec2. I ran into some trouble getting my site-packages and my middleware working on the ec2 server. i am using bitnami djangostack for my AMI but am confused where on the server to put my site-packages (like registration south etc) and where to put my middleware (like pagination).

right now i am running the server and getting the following error:

Traceback (most recent call last):

  File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 283, in run
    self.result = application(self.environ, self.start_response)

  File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)

  File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
    self.load_middleware()

  File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))

ImproperlyConfigured: Error importing middleware pagination.middleware: "No module named pagination.middleware"

you can see the error at the following link

Upvotes: 0

Views: 389

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174624

site-packages is not somewhere you manually add items. Let Python's installation tools - pip and easy_install do the job for you.

As for middleware, it can go anywhere that is in your PYTHONPATH. The best place to put it is in a file that is in one of your app's directory (same place you see models.py); typically this file is called middleware.py

If the middleware is part of a third-party application; first install that application. Typically this is done with sudo easy_install package-name. Use sudo to install it in the global python site-packages directory.

A better approach is to use a virtual environment.

Upvotes: 2

Related Questions