2

I have a python test program to connect to oracle installed in my laptop. the python program is working fine when called from python console(IDLE) but the same program gives "ModuleNotFoundError: No module named 'cx_Oracle' " error when run from anaconda-spyder.

Please suggest.

the program is as follows:


import cx_Oracle
conn=cx_Oracle.connect('user/password@localhost/SID')
cur=conn.cursor()
cur.execute('select * from employee')
for line in cur:
    print(line)
cur.close()
conn.close()

ModuleNotFoundError: No module named 'cx_Oracle'

Pitanshu
  • 21
  • 6
  • That means cx_Oracle is well installed in your Python installation but not in your Anaconda installation. Get rid of your Anaconda installation, problem solved. – 1737973 Sep 15 '19 at 16:27
  • thanks John. But my issue was resolved by the following method. In the Anaconda navigator, select 'Environments', then on the right, change the filter to 'All'. Now you can query for 'cx_oracle', select it and at the bottom, select 'Apply'. Once completed, you should be able to. – Pitanshu Sep 19 '19 at 12:37
  • Possible duplicate of [How can I instal cx\_Oracle package to Anaconda 3 to use with python 3.5](https://stackoverflow.com/questions/35506441/how-can-i-instal-cx-oracle-package-to-anaconda-3-to-use-with-python-3-5) – 1737973 Sep 19 '19 at 14:10

2 Answers2

0

You have to install and configure the module in Anaconda's enviroment as this question is answered:

How can I instal cx_Oracle package to Anaconda 3 to use with python 3.5

And then import the correct module 'oracle'

Teku
  • 35
  • 8
0

In the Anaconda navigator, select 'Environments', then on the right, change the filter to 'All'. Now you can query for 'cx_oracle', select it and at the bottom, select 'Apply'. Once completed, you should be able to

Pitanshu
  • 21
  • 6
  • This is the same as [this](https://stackoverflow.com/a/47317005/1737973) reached via [this](https://stackoverflow.com/a/57946072/1737973). – 1737973 Sep 19 '19 at 12:41