Python – cx_Oracle does not recognize the Oracle software installation location used for installation on Linux

cx_Oracle does not recognize the Oracle software installation location used for installation on Linux… here is a solution to the problem.

cx_Oracle does not recognize the Oracle software installation location used for installation on Linux


have been able to successfully install cx_Oracle for Python 3.4 on my Windows 8 laptop, and now I’m trying to get the same setup on a Linux machine (cx_Oracle and Python 3.4). I got this error when running files from cx_Oracle-5.1.3.tar.gz:

    sudo python3 install
    Traceback (most recent call last):
       File "", line 135, in <module>
          raise DistutilsSetupError("cannot locate an Oracle software " \
    distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation

According to some of the other answers I’ve looked at ( easy_install cx_Oracle (python package) on Windows, I installed these 3 instant client rpm:

rpm -ivh oracle-instantclient12.1-basic-
rpm -ivh oracle-instantclient12.1-devel-
rpm -ivh oracle-instantclient12.1-sqlplus-

Then I set the ORACLE_HOME to the folder they were installed into, which should help python identify the location of the oracle files so that it can install correctly.

Every time I try to run the file, I still get the same “Oracle software installation not found” error.

Any idea what I need to do to successfully install cx_oracle?

Update for more information:

echo $ORACLE_HOME returns /instantclient_12_1, which is where the rpm file is installed.

This is the contents of my /instantclient_12_1 directory:

adrci          tnsnames.ora
BASIC_README     tnsnames.ora_andy
genezi          ojdbc6.jar       uidrvci
glogin.sql          ojdbc7.jar       xstreams.jar   sdk          sqlplus  SQLPLUS_README

This is a bit different from my Windows 8 installation directory – that directory has .dll and .sym files, like orasql12.dll. Should the Linux version installed by the instant client have different files?

Update some solutions:

I found a solution to install cx_Oracle correctly, but only during that shell instance:

I set these two environment variables:

export ORACLE_HOME=/instantclient_12_1

Then I created a symbolic link:

ln -s

After that, go to the cx_oracle folder and do this:

python3 build
python3 install

For some reason, sudo python3 install doesn’t work for this.

Update link to related issue:

My next problem is to have environment variables persist outside of the shell instance so that I don’t have to define environment variables every time. The environment variables I put in profile.d show up on my echo, but python doesn’t import cx_oracle correctly, and for some reason I had to export the environment variables again. I don’t know the correct program for posting different issues related to one issue, so I opened a new issue here :

Linux profile.d environment variables don’t work with cx_oracle in Python

Please help me with this, I feel completely unable to try to get it to work. When I echo them, the environment variables show up, but they only seem to work if you export them again before running the python code.



as Petriborg suggested at build time to set the path LD_RUN_PATH the cx_Oracle shared repository that will be built during installation to contain the Oracle shared library files. As I suggested in the first answer, this eliminates the need for LD_LIBRARY_PATH.

For the RPM you are using, ORACLE_HOME should be set to /usr/lib/oracle/12.1/client. If you are using pip:

$ export ORACLE_HOME=/usr/lib/oracle/12.1/client
$ export LD_RUN_PATH=/usr/lib/oracle/12.1/client/lib:$LD_RUN_PATH
$ pip install cx_Oracle
$ python -c 'import cx_Oracle; print(cx_Oracle.version)'

Read this documentation for some information about installing and executing applications that use client libraries.

Related Problems and Solutions