cx_Oracle: ImportError: DLL load failed: This application has failed cx_Oracle: ImportError: DLL load failed: This application has failed python python

cx_Oracle: ImportError: DLL load failed: This application has failed


OK, what finally solved the problem (not sure whether all steps are necessary and no idea why exactly this and only this worked so far):

  • Download and unzip version 12 from here.
  • Add "ORACLE_HOME" as a Windows environment variable and set its value to ...\instantclient_12_1, (not its containing folder!).
  • Add this same path to the "Path" environment variable.
  • Only now install cx_Oracle.


To help other people with the same problem:

This error tells about 32-64 bit mismatch between some DLL while importing module. Possibilities are:

  1. Different architecture of Python and cx_Oracle (less probable since cx_Oracle installer on Windows warns you if appropriate Python was not found).
  2. Different architecture of cx_Oracle libraries and oci.dll (more probable).

Keep in mind that cx_Oracle uses standart Oracle client (at OCI level), which must be installed on your machine. It searches for oci.dll in several places, including PATH. If it finds oci.dll of wrong version of the client, the error appears.

In case you get this error, check path list in the PATH environment variable. It is likely to contain path to BIN folder of wrong version of Oracle client. If you have several clients, specify in the PATH the appropriate one, or install the appropriate client.

NOTE: ORACLE_HOME does not have an effect for cx_Oracle. In my case only changing of PATH helped. I think the Ruben's solution works because of item 3 ('Add this same path to the "Path" environment variable').


I am using python35 64 bit and oracle express on win 7 (64 bit).I installed cx_Oracle using pip3 (pip3 install cx_Oracle) instead of downloading the installer from pypi.

I faced the same problem.

I solved it by following above guidelines, but instead of 32 bit client, I downloaded the 64 bit version of the instant client (instantclient-basic-windows.x64-11.2.0.4.0.zip) from http://www.oracle.com/technetwork/topics/winx64soft-089540.html.

I then extracted it to c:\oraclexe. And added these environment variables

set ORACLE_BASE=C:\oraclexeset ORACLE_HOME=C:\oraclexe\app\oracle\product\11.2.0\serverset PATH=C:\oraclexe\instantclient_11_2;%PATH%

And ran my django migrate commands:
python manage.py migrate

It worked excellent