Issue building cx_Oracle - => not found


I'm trying to build cx_Oracle for a Python 2.7.2 and Oracle 11g installation but the built cannot find so importing cx_Oracle in Python fails.

/mypath/cx_Oracle-5.1.1/build/lib.linux-x86_64-2.7-11g]$ ldd => not found => /lib64/ (0x00002ae9be290000) => /lib64/ (0x00002ae9be4ab000)
    /lib64/ (0x000000389b600000)

I have in my Oracle client installation directory:

/apps/oracle/client/]$ ls -l* -> /apps/oracle/client/

And the cx_Oracle is picking this lib dir up:

/mypath/cx_Oracle-5.1.1]$ python2.7 build
running build
running build_ext
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/apps/oracle/client/ -I/apps/oracle/client/ -I/apps/bweb/python-2.7.2/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.1
In file included from /apps/oracle/client/,
                 from cx_Oracle.c:10:
/apps/oracle/client/ warning: function declaration isn't a prototype
/apps/oracle/client/ warning: function declaration isn't a prototype
gcc -pthread -shared build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -L/apps/oracle/client/ -lclntsh -o build/lib.linux-x86_64-2.7-11g/

Is something obviously wrong with this setup?



My LD_LIBRARY_PATH contains the lib directory above with


This doesn't seem to make any difference. I rebuild the file and it still shows => not found when I run $ ldd

Python failing to load the built module:

Python 2.7.2 (default, Jan 19 2012, 14:38:32)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot open shared object file: No such file or directory


The issue was related to the LD_LIBRARY_PATH environment variable. Due to restrictions on the setup I'm working with (corp env) I had to build cx_Oracle as another user (system account). i.e. I was running this:

$ sudo -u username python27 build

So even though LD_LIBRARY_PATH was set correctly for me, my version wasn't used when command was executed as a different user. I was able to build successfully by moving the source code to a location where I had permissions and running the build as my user.

7/26/2012 6:37:29 AM

Accepted Answer

Add /apps/oracle/client/ to your LD_LIBRARY_PATH environment variable execute the command below in the terminal before running python or add it into your .bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/oracle/client/
1/31/2013 8:59:10 AM

Yes. You forgot to tell your loader cache tool that it needs to look in that directory for libraries. Add that directory to /etc/ or a similar file and run ldconfig.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow