Installing Django on Shared Server: No module named MySQLdb?

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2009-04-21T03:13:44Z Indexed on 2010/03/28 17:43 UTC
Read the original article Hit count: 891

Filed under:
|
|

I'm getting this error

Traceback (most recent call last):
  File "/home/<username>/flup/server/fcgi_base.py", line 558, in run
  File "/home/<username>/flup/server/fcgi_base.py", line 1116, in handler
  File "/home/<username>/python/django/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/home/<username>/python/django/django/core/handlers/base.py", line 73, in get_response
    response = middleware_method(request)
  File "/home/<username>/python/django/django/contrib/sessions/middleware.py", line 10, in process_request
    engine = import_module(settings.SESSION_ENGINE)
  File "/home/<username>/python/django/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/<username>/python/django/django/contrib/sessions/backends/db.py", line 2, in ?
    from django.contrib.sessions.models import Session
  File "/home/<username>/python/django/django/contrib/sessions/models.py", line 4, in ?
    from django.db import models
  File "/home/<username>/python/django/django/db/__init__.py", line 41, in ?
    backend = load_backend(settings.DATABASE_ENGINE)
  File "/home/<username>/python/django/django/db/__init__.py", line 17, in load_backend
    return import_module('.base', 'django.db.backends.%s' % backend_name)
  File "/home/<username>/python/django/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/<username>/python/django/django/db/backends/mysql/base.py", line 13, in ?
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

when I try to run this script on my shared server

#!/usr/bin/python
import sys, os

sys.path.insert(0, "/home/<username>/python/django")
sys.path.insert(0, "/home/<username>/python/django/www") # projects directory

os.chdir("/home/<username>/python/django/www/<project>")
os.environ['DJANGO_SETTINGS_MODULE'] = "<project>.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

But, my web host just installed MySQLdb for me a few hours ago. When I run python from the shell I can import MySQLdb just fine. Why would this script report that it can't find it?

© Stack Overflow or respective owner

Related posts about django

Related posts about python