how to setup cx_Oracle on python – windows [solved]

When trying to use cx_Oracle in python on windows, I faced following error:

>>> import cx_Oracle
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

In my case, oracle instant client was not installed.
Here is how to solve it.

Steps

  1. Download and unzip oracle instant client appropriate for your configuration: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
    note: on my side i downloaded basic client + odbc + jdbc + sqlplus
  2. Ensure environment variables ORACLE_HOME and PATH points to instant client folder
    note: in windows, go to control panel > System > Advanced system settings > tab “Advanced” > click on “Environment Variables” and define env variables:
    oracle_python_env_variablesoracle_python_env_variables2
  3. Install cx_Oracle client from http://cx-oracle.sourceforge.net/ or https://pypi.python.org/pypi/cx_Oracle/5.2 for windows
  4. Open a new command window and ensure ORACLE_HOME is pointing to correct folder, by running in windows:
    echo %ORACLE_HOME%
  5. Open python console and “run import cx_Oracle”

It should be successful

Sources

Post a Comment

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