Whenever I try to run a command like python manage.py syncdb
, I get the following error:
Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/south/management/commands/__init__.py", line 10, in import django.template.loaders.app_directories File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/template/loaders/app_directories.py", line 21, in mod = import_module(app) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/contrib/admin/__init__.py", line 1, in from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/contrib/admin/helpers.py", line 1, in from django import forms File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/forms/__init__.py", line 17, in from models import * File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/forms/models.py", line 6, in from django.db import conn开发者_JAVA技巧ections File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/__init__.py", line 77, in connection = connections[DEFAULT_DB_ALIAS] File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/utils.py", line 91, in __getitem__ backend = load_backend(db['ENGINE']) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/utils.py", line 32, in load_backend return import_module('.base', backend_name) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 24, in raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module: libclntsh.so.11.1: cannot open shared object file: No such file or directory
Is this resolvable on Ubuntu?
You need to install both cx_Oracle and an Oracle Client.
cx_Oracle can be found here.
An appropriate Oracle Client can be found here.
You will also need to set the LD_LIBRARY_PATH variable before you start your application. This can usually be done (for example):
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
Now you should be able to get past the cx_Oracle error message.
First things first - is this actually a Django problem, or just a cx_Oracle problem? Is cx_Oracle installed correctly? Can you connect to your Oracle database in a Python shell session?
import cx_Oracle
conn = cx_Oracle.connect('/') # user/password@dsn
cursor = conn.cursor()
If this doesn't raise an exception, you have connected successfully.
try easy_install cx_Oracle, it will compile cx_Oracle module from source
精彩评论