Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python and Oracle

I would like to be able to connect to Oracle 10.1.0.2.0 (which is installed on different machine) via python.

My comp is running on Ubuntu 9.04 Jaunty with Python 2.6 installed.

I have downloaded and unpacked instantclient-basic-linux32-10.1.0.5-20060511.zip , set LD_LIBRARY_PATH and ORACLE_HOME to point to the directory where I unpacked it. Then I've downloaded cx_Oracle-5.0.2-10g-py26-1.i386.rpm and installed it:

$sudo alien -i cx_Oracle-5.0.2-10g-py26-1.i386.rpm

When I run

$python -c 'import cx_Oracle'

I get:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/python2.6/cx_Oracle.so: undefined symbol: OCIClientVersion

Help would be very appreciated.

like image 342
todoer Avatar asked Jun 09 '26 14:06

todoer


1 Answers

I believe OCIClientVersion requires Oracle 10g release 2, but you're using release 1.

It looks like cx_Oracle binary you downloaded has been compiled with -DORACLE_10GR2 which makes it include the OCIClientVersion call. Since this is a compile-time-only option there should really be downloads for 10g and 10gR2 separately, but it would seem there aren't:

This module has been built with Oracle 9.2.0, 10.2.0, 11.1.0 on Linux

So you may have to download the cx_Oracle sources and build them yourself. (Consequently you'll need the Python and Oracle client headers.)

Alternatively you could try the cx_Oracle build for Oracle 9i instead. This sounds a bit dodgy but is apparently supposed to work.

like image 190
bobince Avatar answered Jun 12 '26 04:06

bobince