Python cannot load cx_Oracle on Windows 7
Question: I installed python-2.7.amd64.msi and cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi.

I've poked around a lot with PATH and PYTHONPATH environment variables but
nothing has helped loading the cx_Oracle module. Currently PYTHONPATH is set
to C:\Python27\Lib\site-packages

My exceedingly basic program is

    
    
    import sys
    print sys.path
    
    import cx_Oracle
    
    conn_str = u'xxx/xxx@server/XXX'
    conn  = cx_Oracle.connect(conn_str)
    c = conn.cursor()
    c.execute(u'select * from table')
    conn.close()
    

The program output is:

    
    
    ['C:\\Users\\terry\\IdeaProjects\\PythonScripts', 'C:\\Python27\\Lib\\site-packages', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27']
    Traceback (most recent call last):
    File "OracleTest.py", line 4, in <module>
    import cx_Oracle
    ImportError: DLL load failed: The specified module could not be found.
    

I have also added the Registry entries as detailed
[here](http://stackoverflow.com/questions/17872234/how-to-add-python-to-
windows-registry)

This works fine on Linux so it seems I have something wrong with the windows
setup. But I've pretty much run out of ideas.


Answer: This problem turned out (I think) to be that I had not set the ORACLE_HOME
environment variable in Windows. This must point to your Oracle instantclient
directory e.g. ORACLE_HOME=C:\instantclient_11_2

The "I think" part of the story is that even after setting that it did not
help. I uninstalled cx_Oracle and reinstalled it from scratch. This time I
also used the cx_Oracle.EXE from the python web site NOT the cx_Oracle.MSI
file from sourceforge. In theory they would do the same thing. But in theory
it wouldn't have taken me over a day to get the environment set up.

