Skip to content

Instantly share code, notes, and snippets.

@jarshwah
Last active February 23, 2017 22:29
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jarshwah/3863378 to your computer and use it in GitHub Desktop.
Save jarshwah/3863378 to your computer and use it in GitHub Desktop.
Installing cx_Oracle on Linux Redhat 6 using RPMs
# assuming python and pip are already installed
# installing the instantclient is usually where problems happen
# download the following files from oracle
#
# oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
# oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
# oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
# install the rpms
rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
# the sqlplus package isn't specifically needed, but is usually useful for testing and command line sql connections
# configure oracle env (modify exact path based on version of rpm you download)
vim /etc/profile.d/oracle.sh
#!/bin/bash
LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
TNS_ADMIN="/etc/oracle"
export TNS_ADMIN
ORACLE_HOME="/usr/lib/oracle/11.2/client64/lib"
export ORACLE_HOME
# actually set the env vars above in your session
source /etc/profile.d/oracle.sh # or just logout/login
# copy/create your tnsnames.ora file
touch /etc/oracle/tnsnames.ora
# symlink headers to ORACLE_HOME to avoid "cannot locate Oracle include files" error
mkdir /usr/lib/oracle/11.2/client64/lib/sdk
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include
# done. Install cx_Oracle
pip install cx_Oracle
@mbannert
Copy link

used yum install but basically the same setup and rpms as used here. sqlplus64 does work, but I can't run ./configure without errors because of: checking for Oracle OCI headers location... configure: error: variable not set or unable to guess

I mean i got some files in ln -s /usr/include/oracle/11.2/client64 but they can't be found. guess that trick from line 31 does not work for me yet... any idea? RHEL 6.3

@jarshwah
Copy link
Author

@mbannert did you source the /etc/profile.d/oracle file before pip install cx_Oracle? Probably a stupid question, but that's the only thing I could see going wrong here.

What did you try running ./configure against? I didn't want to try installing cx_Oracle from source myself if that's what you were referring to.

@danielskun
Copy link

jarshwah I think you have a mistake,

ORACLE_HOME="/usr/lib/oracle/11.2/client64/lib"

Should be

ORACLE_HOME="/usr/lib/oracle/11.2/client64"

@ankurbansal
Copy link

thanks buddy .

@nsteinmetz
Copy link

Thanks a lot for this ; you will also need python-devel package for the compilation

@seiriosPlus
Copy link

thankyou very much!

@vrtlpilot
Copy link

Thank you. But in my case, I changed that code

symlink headers to ORACLE_HOME to avoid "cannot locate Oracle include files" error

mkdir /usr/lib/oracle/11.2/client64/sdk
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/sdk/include
because for me does worked that variable
ORACLE_HOME="/usr/lib/oracle/11.2/client64"

@nemmeviu
Copy link

Nice!! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment