Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: import cx_Oracle ImportError: No module named cx_Oracle error is thown

Tags:

python

I try to write a script in .py for oracle connectivity:

#!/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()

I get the following error:

Traceback (most recent call last):
  File "test_SQLPython.py", line 3, in ?
    import cx_Oracle
ImportError: No module named cx_Oracle

Any help would be appreciated? Thanks.

like image 586
Sujith Avatar asked Mar 28 '12 13:03

Sujith


1 Answers

Tried installing it via rpm posted in above answers, but it didn't worked. What worked instead is plain pip install.

pip install cx_oracle

The above command installed cx_oracle=6.1 Please note that I'm using python 2.7.14 Anaconda release and oracle 12c.

like image 165
Ayush Vatsyayan Avatar answered Oct 01 '22 04:10

Ayush Vatsyayan