Question

I´m having serious trouble to get Django to work with my Apache/mod_wsgi installation accessing Oracle. I have this setup running on a CentOS 6 host, and I'm getting this error in my Apache logs:

Error loading cx_Oracle module: libclntsh.so.10.1: cannot open shared object file: No such file or directory

If I try to import cx_Oracle from the Python command line it works fine in both root and apache users. I set ORACLE_HOME and LD_LIBRARY_PATH ($ORACLE_HOME/lib) correctly: in ~/.bashrc, /etc/ld.so.conf.d/oracle.conf, ~/.bash_profile, anywhere I can set an env var.

I've also tried making a hard link or symbolic link to $ORACLE_HOME/lib/libclntsh.so.10.1 in /usr/lib, but I got a permission error, no matter how many chmod 777 I issue from /usr down to /usr/lib and the file.

I added the ORACLE_HOME and LD_LIBRARY_PATH to /etc/sysconfig/httpd with no change.

Apparently this error occurs only when the Apache user runs the import cx_Oracle command, although logging in with this user I can run the command from the Python interpreter.

Was it helpful?

Solution

When you build cx_Oracle from source code, set the LD_RUN_PATH environment variable to the path to the lib directory containing Oracle .so files and it will embed the location in the cx_Oracle .so and will know where to get libclntsh.so at runtime without needing LD_LIBRARY_PATH set.

OTHER TIPS

There is a better solution without reinstalling.. "appended /app/oracle/oracle/product/10.2.0/db_1/lib to /etc/ld.so.conf and ran ldconfig." from http://catherinedevlin.blogspot.com/2005/10/cxoracle-and-ubuntu.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top