Cx_oracle and python 2.7

Im using python 2.7 and cx_oracle (Windows x86 installer (Oracle 10g, Python 2.7)) and I have a bad time to install this simple example below:

import cx_Oracle connection = cx_Oracle.connect('user/ pass@someserver :port') cursor = connection.cursor() cursor.execute('select sysdate from dual') for row in cursor: print row connection.close() 

Error message:

 Traceback (most recent call last): File "C:\ORACON.py", line 1, in <module> import cx_Oracle ImportError: DLL load failed: The specified module could not be found. 

Currently, I have done the following:

1) installed the cx_oracle binary;

2) downloaded instantclient_10_2 from oracle website and exported environment path;

Does anyone know what is missing?

Thank you for reading this.

+6
source share
2 answers

I managed to solve this problem with the following steps:

  • Download instantclient-basic-win32-10.2.0.5 from Oracle website

  • unzipped to my c: \ named oraclient

  • Created a directory structure C: \ oraclient \ network \ admin to add TNSNAMES.ORA

  • Added TNS_ADMIN env var pointing to C: \ oraclient \ network \ admin

  • Added env var ORACLE_HOME pointing to C: \ oraclient \

After that, I used the following code:

 import cx_Oracle con = cx_Oracle.connect('theuser', 'thepass', 'your DB alias on your TNSNAMES.ORA file ') cur = con.cursor() if cur.execute('select * from dual'): print "finally, it works!!!" else: print "facepalm" con.close() 

I hope this helps someone.

+16
source

See this answer: fooobar.com/questions/596067 / ...

ignore it .... making up the other 17 bytes that are needed ...

-1
source

All Articles