我正在使用python 2.7和cx_oracle(Windows x86安装程序(Oracle 10g,Python 2.7)),并且很难设置这个简单的示例:
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()
错误讯息:
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.
目前,我所做的是:
1)安装了cx_oracle二进制文件;
2)从oracle网站下载instantclient_10_2并导出环境路径;
任何人都知道我失踪了什么?
感谢您抽出时间阅读本文。
答案 0 :(得分:21)
我能够通过以下步骤解决此问题:
从Oracle Website下载 instantclient-basic-win32-10.2.0.5
解压缩到我的c:\中,名称为oraclient
创建目录结构C:\ oraclient \ network \ admin以添加TNSNAMES.ORA
添加了指向C:\ oraclient \ network \ admin
添加了指向C:\ oraclient \
之后我使用了以下代码:
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()
我希望它有所帮助。
答案 1 :(得分:-3)
请参阅此答案:https://stackoverflow.com/a/19552263/496289
忽略这个....组成其他需要的17个字节...