20

I need install cx_Oracle for Python 2.5 on Linux (Linux 2.6.18-371.1.2.el5 i686). I have installed Oracle client 10.2.0.4.

I have tried following: 1. Download cx_Oracle tar.gz from http://sourceforge.net/projects/cx-oracle/files/. I don't know which of listed version are suitable for python 2.5 and Oracle client 10.2.0.4, so try cx_Oracle-5.1.tar.gz. Unpacked tar, go to unpacked folder and run python setup.py install. I got error:

Traceback (most recent call last):
File "setup.py", line 187, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files

In .bash_profile I have setted oracle path:

export ORACLE_HOME=/usr/oracle/10.2.0.4/client
export PATH=$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

How fix such error, maybe I need another version of cx_Oracle tar?

  1. Run pip install cx_Oracle. Got error:

Downloading/unpacking cx-Oracle

Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement cx-Oracle
No distributions at all found for cx-Oracle

Could someone advise me right solution?

Update After suggestion in response I got following error:

...
cx_Oracle.c:496: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from  pointer without a cast
cx_Oracle.c:497: error: âOCI_UCBTYPE_EXITâ undeclared (first use in this function)
cx_Oracle.c:497: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
cx_Oracle.c:498: error: âOCI_UCBTYPE_REPLACEâ undeclared (first use in this function)
cx_Oracle.c:498: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
error: command 'gcc' failed with exit status 1
khris
  • 4,809
  • 21
  • 64
  • 94

4 Answers4

14

When you run setup.py it will check for any of these folders on your ORACLE_HOME.

possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
        "sdk/include"]

Also the instant client sometimes places the include files, such as oci.h, in /usr/include/oracle//client, if there is no 'include' directory under ORACLE_HOME create a symbolic link to it.

sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include

Looks like you're missing the Client SDK

fn.
  • 2,788
  • 2
  • 27
  • 29
  • 1
    I tried create symbolic link, it doesn't help, but I try just add empty folder include in /usr/oracle/10.2.0.4/client/network. This fixed error, but I got new, please see in updated question for details – khris Jul 03 '14 at 12:03
  • @khris Try downloading the sdk and extracting on your client, it should create the sdk/include folder. I added the link to the answer. – fn. Jul 03 '14 at 20:33
  • Could you pleas give direct link becase in Client SDK page I see a lot of stuff, like Content Management SDK and don't know what exactly I need to download. Thanks – khris Jul 04 '14 at 09:59
  • I cannot directly link to the file, go to http://www.oracle.com/technetwork/topics/linuxsoft-082809.html and search for 'Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client' for your oracle version. – fn. Jul 04 '14 at 11:20
  • 1
    Thank you! The following commands helped me: `sudo mkdir $ORACLE_HOME/sdk/` `sudo ln -s /usr/include/oracle/12.1/client $ORACLE_HOME/sdk/include` – Dennis Golomazov Nov 24 '14 at 09:05
  • I have the SDK and I still get the same error. See http://stackoverflow.com/questions/31435990/cx-oracle-distutils-errors-distutilssetuperror-cannot-locate-oracle-include-fi – Zoltan Fedor Jul 15 '15 at 16:29
1

Make sure you install the instant client sdk for you OS.

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

etlds
  • 5,810
  • 2
  • 23
  • 30
1
  1. Install oracle_client_basic

    oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
    
  2. Using pip install

    python -m pip install cx_Oracle
    
  3. Adding ldconfig

    1. Find your client location, for example: /u01/app/oracle/product/11.2.0/client_1/lib
    2. vi /etc/ld.so.conf.d/oracle.conf

      Add this location into it:

      /u01/app/oracle/product/11.2.0/client_1/lib
      
    3. ldconfig
  4. import cx_oracle
james.peng
  • 373
  • 1
  • 3
  • 13
0

Make sure that you've a client sdk present in your path.

Also I had to do add this to my .bash_rc

export DYLD_LIBRARY_PATH=$ORACLE_HOME

In addition to this, Python 2.7 does not come with Python.h which is available by default in Python 3.4. So I would also suggest to install python-devel package

yum install python-devel

That should resolve the issue.

ARK
  • 57
  • 1
  • 8