So I found Help installing cx_Oracle but am still stuck. I downloaded the latest instantclient from oracle, and set ORACLE_HOME to the location of the extracted files (both direct and with a bin folder between the ORACLE_HOME value and the files), but easy_install is popping an error when running setup.py saying it can't locate the Oracle include files. I did notice that only the 11g dll is in the folder, do I need all 3 drivers present for setup to complete? If so, where do I even get them?
Honestly it is a hell of a lot easier to install cx_Oracle from one of the binary installers they have, than from source.
Download the latest version of basic, sqlplus and sdk packages that fit your architecture (32 or 64bits):
oracle-instantclient<version>-basic-<version_full>.<arch>.rpm
oracle-instantclient<version>-sqlplus-<version_full>.<arch>.rpm
oracle-instantclient<version>-devel-<version_full>.<arch>.rpm
.Install the RPMs using alien. For example, at the time of this writing:
$ sudo alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
Add necessary environment variables (I personally did put it in /etc/environment
then logoff/back in to reload the env):
ORACLE_HOME=/usr/lib/oracle/<version>/client64/lib/
LD_LIBRARY_PATH=/usr/lib/oracle/<version>/client64/lib/
$ sudo ln -s /usr/include/oracle/<version>/client $ORACLE_HOME/include # for 32bits arch, OR
$ sudo ln -s /usr/include/oracle/<version>/client64 $ORACLE_HOME/include # for 64bits arch
Create /etc/ld.so.conf.d/oracle-instantclient<version>-basic.conf
and /etc/ld.so.conf.d/oracle.conf
(for more recent versions, at least since 12.1) containing:
/lib
/usr/lib/oracle/<version>/client/lib ; for 32bits arch, OR
/usr/lib/oracle/<version>/client64/lib ; for 64bits arch
Reload ldconfig cache (use -v
flag if you want some verbose):
$ sudo ldconfig
You might need to install libaio1
.
Assuming we have installed Oracle Instant Client 10, you have different alternatives to install cx_Oracle:
$ pip install cx_oracle
(linux only)Older versions (version less than 5.1.2 are .msi and .rpm files) can be downloaded from here. Install the RPMs using alien. For example, at the time of this writing:
$ sudo alien -i cx_Oracle-5.0-10g-py25-1.x86.rpm
To test, python -c 'import cx_Oracle; print cx_Oracle'
should return the modules with its version.