Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle Mac

I have cx_Oracle installed and I can successfully import it. But when I try to establish an Oracle connection, I get this error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle

My operating system is MacOSX, and my ORACLE_HOME is pointing to instantclient_11_2.

like image 758
Rijo Simon Avatar asked Mar 24 '17 18:03

Rijo Simon


2 Answers

First thing first.

Check if your cx_oracle is built for the exactly same version as your Oracle client.

import cx_Oracle
cx_Oracle.clientversion()

This should return the version it's expecting to find.

If the versions differ, you should rebuild it against the correctly version.

like image 86
fn. Avatar answered Oct 05 '22 20:10

fn.


For instant client, do not set ORACLE_HOME. Instead follow these instructions:

cd $HOME
mkdir -p lib
cd lib
cp /the/location/to/instantclient_11_2/*dylib* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib

If you are able to use Instant Client 12.1 things are a bit simpler

cd $HOME
mkdir -p lib
cd lib
ln -s /the/location/to/instantclient_12_1/libclntsh.dylib.12.1 libclntsh.dylib

If you also download and extract the SQL*Plus package you can verify that your client installation is working properly.

like image 34
Anthony Tuininga Avatar answered Oct 05 '22 19:10

Anthony Tuininga