Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to Oracle database with Django on Ubuntu

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 connections
  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?

like image 972
damon Avatar asked Dec 02 '10 17:12

damon


People also ask

Which package provides the utilities to work with Oracle database in Python?

Oracle Application Container Cloud Service lets you deploy Java SE, Node. js, PHP, and Python applications to the Oracle Cloud.


1 Answers

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.

like image 189
Jon Avatar answered Nov 14 '22 15:11

Jon