How to install cx_Oracle, a library for connecting to Oracle from Python.
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.3
BuildVersion: 16D32
$ python --version
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
$ pip --version
pip 9.0.1 from /Users/nobukatsu/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages (python 3.5)
http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
From the above page
--instantclient-basic-macos.x64-[version number] .zip --instantclient-sdk-macos.x64-[version number] .zip
Download the two, unzip them, and place them in a suitable location.
Example:
/Users/nobukatsu/devel/library/oracle/instantclient_12_1
$ pwd
/Users/nobukatsu/devel/library/oracle/instantclient_12_1
$ ln -s libclntsh.dylib.12.1 libclntsh.dylib
$ ln -s libocci.dylib.12.1 libocci.dylib
Set environment variables in .bash_profile etc.
export ORACLE_HOME=~/devel/library/oracle/instantclient_12_1
export PATH=$ORACLE_HOME:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
export FORCE_RPATH=1
pip install --no-cache-dir cx_oracle
If no error occurs after executing the following, the installation is successful.
python -c "import cx_Oracle"
Recommended Posts