Error when importing cx_Oracle module [Python]

17,520

Solution 1

Have you tried import cx_Oracle (upper-case O) instead of import cx_oracle?

Solution 2

I had this same issue under Windows. I used Dependency Walker to open up the cx_Oracle.pyd file in C:\Python\Libs\site-libraries\ and reviewed the findings that dependency walker gave.

Dependency Walker showed me that in this case I had the x86 version of Python 2.7.2 installed and x64 version of the Oracle client & client DLL (oci.dll) and was trying to use the x64 version of the cx_Oracle module. With that knowledge I installed Python 2.7.2 x86_64 for Windows and everything was right as rain. The alternative was to install the x86 version of the Oracle client & cx_Oracle which is much more of a PITA than installing a new Python interpreter.

Also, as this was news to me, you must have the Oracle client installed as well as it provides the 'OCI.dll' client library that cx_Oracle uses. It's located here: Oracle Client Installer Windows x64. Probably helps if one reads the documentation. ;)

Either way, Dependency walker could give you a big clue as to what your issue is if you're having import errors. Unfortunately on-import error messages can be quite ambiguous. I received the same error you referenced and number of other less than specific errors as well.

Solution 3

after installing the cx_Oracle download the instant client form oracle owth all DLLs , then copy then in the same directory of cx_Oracle.pyd , it will work directly

tried and worked for me.

Share:
17,520
Gašper
Author by

Gašper

Updated on June 28, 2022

Comments

  • Gašper
    Gašper almost 2 years

    I use Windows 7 64 bit and Oracle 10g. I have installed python-2.7.2.amd64 and cx_Oracle-5.1-10g.win-amd64-py2.7.

    When I importing cx_Oracle module I get this error: Traceback (most recent call last): File "C:\Osebno\test.py", line 1, in import cx_oracle ImportError: No module named cx_oracle

    Can someone please tell me what is wrong?

  • Gašper
    Gašper almost 13 years
    I tried importing cx_Oracle and I get the same error. I use one version of Python (Python 2.7.2) PATH: >>> import sys >>> print sys.path ['C:\\Osebno', 'C:\\Python27\\Lib\\idlelib', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode'] I can see cx_Oracle.pyd in folder C:\Python27\Lib\site-packages\ It must be some kind of problem with Win 7 64 bit and Oracle drivers?
  • iprashant
    iprashant almost 8 years
    Hey! i know i am bit late but i am facing similar issue. I have my oracle db in x machine and i am on Y machine, in Y i have python 3.5(64bit), also installed cx_Oracle. But when i open pycharm and try to import it says no module found. If you resolved that issue then please help me out.