我尝试在 .py 中编写一个脚本以实现 Oracle 连接:
#!/usr/bin/python
import cx_Oracle
connstr='username/pwd@database'
conn = cx_Oracle.connect(connstr)
curs = conn.cursor()
curs.execute('select * from table1;')
print curs.description
for row in curs:
print row
conn.close()
我收到以下错误:
Traceback (most recent call last):
File "test_SQLPython.py", line 3, in ?
import cx_Oracle
ImportError: No module named cx_Oracle
有任何帮助吗? 谢谢。
最佳答案
尝试通过上面答案中发布的 rpm 安装它,但没有成功。相反,有效的方法是简单的 pip install
。
pip install cx_oracle
以上命令已安装cx_oracle=6.1
请注意,我使用的是 python 2.7.14 Anaconda 版本
和 oracle 12c
。
关于Python:导入cx_Oracle导入错误:没有名为cx_Oracle的模块错误被抛出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9908055/