Cx_Oracle.InterfaceError: Unable to access Oracle environment from 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 points to instantclient_11_2.

+6
source share
3 answers

First of all.

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

import cx_Oracle
cx_Oracle.clientversion()

This should return the expected version.

If the versions are different, you must rebuild it in the correct version.

+2
source

For an 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

Instant Client 12.1,

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

SQL * Plus, .

+2

Did you try to establish how you connected? It looks like you configured it correctly.

Try the following (fill in your personal information):

ip_addr = 'ip address'
port = 1521
sid = 'sid'
dsn_tns = cx_Oracle.makedsn(ip_addr, port, sid)
db = cx_Oracle.connect('username', 'password', dsn_tns)

If this does not work, make sure yours is LD_LIBRARY_PATHinstalled correctly.

+1
source

Source: https://habr.com/ru/post/1016014/


All Articles