how to set up cx_Oracle on ubuntu [solved]

I tried installing oracle client to use it with sqlalchemy and ended up with a nasty error message:

distutils.errors.DistutilsSetupError: cannot locate Oracle include files

To setup cx_Oracle so that it can be imported from python, proceed as follow:

  1. install by running:
    sudo apt-get install libaio1
  2. download instant client appropriate for your platform from oracle website:
    SDK and ODBC packages must be downloaded too.
    note: on my side i downloaded:
  3. convert into .deb package:
    sudo alien -d *instantcl*.rpm

    note: you may need to install alien (sudo apt-get install alien) if not already done

  4. install created package:
    sudo dpkg -i *instantcl*.deb
  5. create file sudo vi /etc/ with content pointing to oracle default installation directory:
  6. create environments variable:
    export ORACLE_HOME=/usr/lib/oracle/12.1/client64

    note: make changes permanent by adding declaration into ~/.bashrc

  7. run
    sudo ldconfig
  8. install python library:
    python -m pip install cx_oracle

    note: above syntax is for python 3.5 and above, otherwise run “pip install cx_oracle”, you may also need to install pip via “sudo apt-get install python3-pip”

  9. Log in a python console and ensure “import cx_Oracle” is successful!




Post a Comment

Your email is never published nor shared. You're allow to say what you want...