# yum install gcc
Installing Python's Oracle client CX_oracle is not as easy as:
$ pip install CX_oracle
If you run the command on a fresh CentOS 7.1 installation you will get an error like this:
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
So we need to install Oracle's client on our linux box. Easiest way to do this, is to download & install Oracle's Instant Client (you will need an Oracle login to do that). Pick the "Instant Client for Linux x86-64" for your CentOS installation. You will need "basic", "devel" (to get libraries to compile CX_oracle) and "sqlplus" (to do some testing that your client installation works). When presented with the options, get the RPM versions. As of this writing, latest version are:
Then, install it as a root by running:
# rpm -ivh oracle-instantclient12.1-*.rpm
You should get something like this:
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
# rpm -ivh oracle-instantclient12.1-*.rpm
You should get something like this:
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient12.1-basic-12################################# [ 33%]
2:oracle-instantclient12.1-devel-12################################# [ 67%]
3:oracle-instantclient12.1-sqlplus-################################# [100%]
When done, Oracle's Instant Client will install here:
/usr/lib/oracle/12.1/client64/
First time you try to run "sqlplus" by typing
# sqlplus64
You will get an error like this:
sqlplus64: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
This is Oracle telling you it can't find appropriate libraries. To fix this and setup additional Oracle stuff in your environment, create a file named "/etc/profile.d/oracle.sh" with this content:
ORACLE_HOME=/usr/lib/oracle/12.1/client64
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_HOME LD_LIBRARY_PATH PATH
Restar your session (logout and login again, no need to reboot) and try your client's installation by running sqlplus:
# sqlplus
SQL*Plus: Release 12.1.0.2.0 Production on Tue May 10 10:26:23 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter user-name: system@"192.168.16.67:1521/XE"
Enter password:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> select 1 from dual;
1
----------
1
SQL> quit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
Replace "192.168.16.67:1521/XE" with the corresponding Oracle database connection parameters. If connection was successful, you are all set to install "CX_oracle".
Try again running:
$ pip install CX_oracle
Voilà!
# pip install CX_oracle
Downloading/unpacking CX-oracle
Downloading cx_Oracle-5.2.1.tar.gz (113kB): 113kB downloaded
Running setup.py egg_info for package CX-oracle
Installing collected packages: CX-oracle
Running setup.py install for CX-oracle
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/oracle/12.1/client64 -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -L/usr/lib/oracle/12.1/client64/lib -L/usr/lib64 -lclntsh -lpython2.7 -o build/lib.linux-x86_64-2.7-12c/cx_Oracle.so
Successfully installed CX-oracle
Cleaning up...
You can test your CX_oracle installation with this piece of code:
import cx_Oracle
db = cx_Oracle.connect('system', '******', '192.168.16.67:1521/XE')
cursor = db.cursor()
st = cursor.execute("select 1 from dual")
all = st.fetchall()
print(all)
When run, the above code should print:
[(1,)]
Hi,
ReplyDeleteIt is very good article on installation of oracle in centos, Can We do it this in Redhat linux??check our website for oracle EBs and Financials information.
Thank you,
Oracle EBS training
This comment has been removed by the author.
ReplyDeleteThank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information.
ReplyDeleteOracle Fusion Financials Online Training
Thanks for sharing such a great blog very pleased
ReplyDeleteTechnoSizzle
Hey Really Thanks for sharing the best information regarding oracle applications,hope you will write more great blogs.
ReplyDeleteoracle fusion financials online training
great blog
ReplyDeletehttp://www.maccracks.online/
Now you can win free stuff online, free giveaways, enter every day to win latest iphones, smartphones, macbooks, laptops, accessories, technology and much more.
ReplyDeleteParticipate, Win & Keep A Free Apple iPhone XR
Hello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
ReplyDeleteData science Course Training in Chennai |Best Data Science Training Institute in Chennai
RPA Course Training in Chennai |Best RPA Training Institute in Chennai
AWS Course Training in Chennai |Best AWS Training Institute in Chennai
Devops Course Training in Chennai |Best Devops Training Institute in Chennai
Selenium Course Training in Chennai |Best Selenium Training Institute in Chennai
Java Course Training in Chennai | Best Java Training Institute in Chennai
It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
ReplyDeleteData science Course Training in Chennai |Best Data Science Training Institute in Chennai
RPA Course Training in Chennai |Best RPA Training Institute in Chennai
AWS Course Training in Chennai |Best AWS Training Institute in Chennai
Devops Course Training in Chennai |Best Devops Training Institute in Chennai