Kris Edison
Kris Edison

Reputation: 119

Can't get Python 3.2.5 and cx_Oracle to work

I need to connect to Oracle database using python. So, I did the following:

  1. I downloaded instantclient_11_2 basic and sdk from Oracle site.
  2. Put the files on /opt/ora/instantclient
  3. export ORACLE_HOME=/opt/ora/instantclient
  4. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
  5. cd $ORACLE_HOME && ln -s libclntsh.so.11.1 libclntsh.so
  6. Downloaded and installed cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm

But when I tried to run import cx_Oracle I got this error:

ImportError: No module named cx_Oracle

According to cx_Oracle site I need to Place the file cx_Oracle.pyd or cx_Oracle.so anywhere on your Python path. But I can't find those files after installing cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm..

By the way, I also tried to install using zipped version but I got a lot error upon building like error: command 'gcc' failed with exit status 1

Is there anything I did wrong?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Got it solved guys. I upgraded my python to latest, used cx_Oracle for python33, and instantclient11.2..

Upvotes: 0

Views: 1418

Answers (1)

KKCroissant
KKCroissant

Reputation: 46

1: For your failed building, please give more details. Probably because you don't have the python development headers installed ("python-devel")

2: You need Oracle client installed as well, because cx_Oracle is just a linker between Python and the Oracle Client. Fast way is to get "Instant Client".

From the cx-oracle's README:

Please note that an Oracle client (or server) installation is required in order to use cx_Oracle. If you do not require the tools that come with a full client installation, it is recommended to install the Instant Client which is far easier to install.

Upvotes: 1

Related Questions