I've had to put cx_Oracle (python Oracle database connector) on macOS and Linux, and both processes were similar but poorly documented on Oracle's website.
These instructions were written and tested using the client 12.1. The instructions for any 12.x are the same, but you may need to change 12_1
to 12_2
in commands if you are using version 12.2, etc.
-
Download 64 bit (easy to download 32 by mistake) basic + sdk instantclient from Oracle website (Note: you need an account, I used throwaway email)
-
mkdir /usr/local/lib/oracle
(we should not use/usr/lib
in macOS due to SIP)- Note: you may choose any directory you wish, such as
/opt/oracle
on Linux but be sure to replace the directories in any instructions below with your choice.
- Note: you may choose any directory you wish, such as
-
Unzip + move the downloaded files directly to
/usr/local/lib/oracle/instantclient_12_1
tar -xvf instantclient-basic-macos.x64-11.2.0.4.0.zip -C /usr/local/lib/oracle
tar -xvf instantclient-sdk-macos.x64-11.2.0.4.0.zip -C /usr/local/lib/oracle
-
Link libraries to non-version specific names (
cd /usr/local/lib/oracle/instantclient_12_1
if you haven't)ln -s libclntsh.dylib.12.1 libclntsh.dylib
ln -s libocci.dylib.12.1 libocci.dylib
-
Add environment variables to PATH (add to .profile, .bash_profile, .zshrc etc.)
export ORACLE_HOME=/usr/local/lib/oracle/instantclient_12_1
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME:$PATH
-
Install cx_Oracle with pip
pip install cx_Oracle
-
Test that it's working properly
python
import cx_Oracle
The import should execute without an error, and you're off and running.
Hi Thanks for the instructions.
Everything works fine until step 7. Error I get is