Can't Find libclntsh.so.11.1 With Oracle Backend

4,233 views
Skip to first unread message

Jon Blake

unread,
Sep 10, 2012, 12:41:00 AM9/10/12
to django...@googlegroups.com
I have worked through the Django tutorial parts 1 and 2 with an Oracle back end using the development server. Everything worked fine. I now want to use a real server - Apache + mod_wsgi. I've got to the point where I get an "Improperly Configured at /" page, which shows the following:

Exception Type:     ImproperlyConfigured
Exception Value:     Error loading cx_Oracle module: libclntsh.so.11.1: cannot open shared object file: No such file or directory
Exception Location:     /usr/lib/python2.7/site-packages/django/db/backends/oracle/base.py in <module>, line 46

Line 46 raises exception ImproperlyConfigured on a try block which imports cx_Oracle.

cx_Oracle is properly installed. In my desktop environment:

$ python
>>> import cx_Oracle

works fine. I also export LD_LIBRARY_PATH which points to where libclntsh.so.11.1 resides. If I clear this environment
variable, import cx_Oracle fails with:

ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory

It looks like I have to tell my app what my path to libclntsh.so.11.1 is. I have added:

os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/lib'

to my app's wsgi.py file, but this does resolve my problem.

Can anyone assist with how to progress this?

Environment:
  O/S:     Fedora14
  Apache: 2.2.17
  Python: 2.7
  mod_wsgi: 3.2
  cx_Oracle: 5.1
  Django: 1.4.1

Jon Blake

unread,
Sep 10, 2012, 1:52:09 AM9/10/12
to django...@googlegroups.com
Just an edit to my original post: ... but this does not resolve my problem. Sorry for any confusion.

Ian

unread,
Sep 10, 2012, 12:11:06 PM9/10/12
to django...@googlegroups.com
On Sunday, September 9, 2012 10:41:00 PM UTC-6, Jon Blake wrote:
It looks like I have to tell my app what my path to libclntsh.so.11.1 is. I have added:

os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/lib'

to my app's wsgi.py file, but this does resolve my problem.


LD_LIBRARY_PATH has to be set before the process starts to be honored.  So it's not sufficient to set it in the wsgi file with os.environ; you need to use an Apache SetEnv directive, or use a script to export it in the Apache process's environment variables when Apache is started.  Or as a third option, use ldconfig to make the Oracle library path globally visible.

Cheers,
Ian

Jani Tiainen

unread,
Sep 10, 2012, 4:15:31 PM9/10/12
to django...@googlegroups.com
I've been using ldconfig to handle libs. It's easy as runnig following few commands as a root. (Though I always use oracle instantclient, it's just simpler in many cases):

$ echo  /oracle/product/11.1.0/db_1/lib  > /etc/ld.so.conf.d/oracle.conf
$ ldconfig

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/z8aKjhUtm3QJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

Jon Blake

unread,
Sep 10, 2012, 7:05:16 PM9/10/12
to django...@googlegroups.com
Thanks, Jani and Ian. I've used the ldconfig approach to fix this problem. Now getting a "ImportError at /" page, for which I'll post another question.

Иван Земцов

unread,
Sep 11, 2012, 2:33:23 AM9/11/12
to django...@googlegroups.com
set the ORACLE_HOME  variable of the user who run site
SuexecUserGroup inof inof
env |grep ORA
ORACLE_BASE=/usr/lib/oracle
ORACLE_HOME=/usr/lib/oracle/11.2/client64/

To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/imnCF82L9_EJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
С уважением, Иван
Reply all
Reply to author
Forward
0 new messages