Cx_Oracle does not recognize installation location of Oracle software to install on Linux

I was able to successfully install cx_Oracle for use with Python 3.4 on my Windows 8 laptop, and now I am trying to get the same setup (cx_Oracle with Python 3.4) on a Linux machine. When running the setup.py file from cx_Oracle-5.1.3.tar.gz I get the following error:

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

      

Following some other answers, I looked ( easy_install cx_Oracle (python package) on Windows , https://gist.github.com/jarshwah/3863378 ) I installed these 3 instant client rpms:

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

      

And then I set the ORACLE_HOME to the folder where they were installed, which should help python determine the location of the oracle files so that it can install correctly.

I still get the same "cannot install Oracle software installation" error every time I try to run setup.py.

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

Update for more information:

echo $ ORACLE_HOME returns /instantclient_12_1

where rpm files are installed.

This is the contents of the my / instantclient_12_1 directory:

adrci                  libnnz12.so       libsqlplusic.so  tnsnames.ora
BASIC_README           libocci.so        libsqlplus.so    tnsnames.ora_andy
genezi                 libocci.so.12.1   ojdbc6.jar       uidrvci
glogin.sql             libociei.so       ojdbc7.jar       xstreams.jar
libclntshcore.so.12.1  libocijdbc12.so   sdk
libclntsh.so           libons.so         sqlplus
libclntsh.so.12.1      liboramysql12.so  SQLPLUS_README

      

This is slightly different from the directory I have for my Windows 8 installation - it has files .dll

and .sym

eg orasql12.dll

. If the instant client version of Linux has different files?

Update with partial solution:

I found a solution that installed cx_Oracle correctly, but only during this shell instance:

I have set these two environment variables:

export ORACLE_HOME=/instantclient_12_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

      

And then I created a symbolic link:

ln -s libclntsh.so.12.1 libclntsh.so

      

After that, going to the folder cx_oracle

and it worked:

python3 setup.py build
python3 setup.py install

      

For some reason sudo python3 setup.py install

doesn't work for this.

Update with link to related question:

My next problem is to keep environment variables outside of the shell instance, so I don't have to define environment variables every time. The environment variables I put in profile.d show up when I iterate over them, but python fails to import cx_oracle correctly and I have to export the environment variables for some reason. I don't know the correct procedure to post another question related to one, so I opened a new question here:

Linux profile.d environment variables not working with cx_oracle in Python

Please help me with this, I feel totally stuck trying to get it to work. Environment variables show up when I echo them, but they seem functional if I export them again before running the python code.

+3


source to share


2 answers


Update

As Petriborg suggested , LD_RUN_PATH

a build-time installation would include the path to the Oracle shared library files in the shared library cx_Oracle

that is created during installation.This removes the need LD_LIBRARY_PATH

, as I suggested in my first answer.




For the RPMs you are using, you ORACLE_HOME

should install in /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)'
5.1.3

      

Read this documentation for some information on installing and running applications that use the client libraries.

+4


source


When I tried to install cx_Oracle with only the LD_LIBRARY_PATH variable on Ubuntu 16.04 using python 2.7.12 and Oracle 12.1.0.2 client, install failed and looks for header files that are no longer available for Oracle 12.1.0.2 client. It works fine with LD_RUN_PATH



0


source







All Articles