Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognizing cx_Oracle install within PyDev

I am on Windows 10 Pro 64-bit Anniversary Edition using Python 3.5.2 (Anaconda 4.1.1). I download the latest Oracle 12c Instant Client instantclient-basic-windows.x64-12.1.0.2.0.zip and instantclient-sdk-windows.x64-12.1.0.2.0.zip into C:\instantclient and put C:\instantclient on my PATH. Then I download the installer cx_Oracle-5.2.1-12c.win-amd64-py3.5.exe directly from PyPI.

Now I can start an Anaconda python prompt and type import cx_Oracle and it is successful.

>>> import cx_Oracle
>>>

By when I go into my PyDev installation on Eclipse Neon (4.6), the import cx_Oracle line in my source file still shows an error as an unresolved import.

  • I went into Windows > Preferences > PyDev > Interpreters > Python Interpreter and removed the Anaconda interpreter (C:\bin\anaconda3\python.exe) and added it back. I restarted Eclipse, but no luck.
  • I issued a Project > Clean on all my projects and restarted Eclipse. It still shows import cx_Oracle as an unresolved import.

How can I get PyDev to see my cx_Oracle package installation?

Note that there are a lot of supposed answers that do not work for me; I've tried all the suggestions, as indicated above.

  • PyDev does not recognize imports
  • How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?
  • Force eclipse to reload Python modules
  • pydev doesn't find python library after installation
like image 647
Garret Wilson Avatar asked Sep 19 '16 19:09

Garret Wilson


People also ask

How do you check cx_Oracle is installed or not?

You can check if you have the cx_Oracle package installed by running the pip show cx_Oracle command. Copied! The pip show cx_Oracle command will either state that the package is not installed or show a bunch of information about the package, including the location where the package is installed.

Does cx_Oracle require Oracle client?

Using cx_Oracle requires Oracle Client libraries to be installed. These provide the necessary network connectivity allowing cx_Oracle to access an Oracle Database instance. Oracle Client versions 19, 18, 12 and 11.2 are supported.

What is import cx_Oracle in Python?

cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions. cx_Oracle 8.3 was tested with Python versions 3.6 through 3.10.

Is cx_Oracle open source?

cx_Oracle is distributed under an open-source license (the BSD license). A detailed description of cx_Oracle changes can be found in the release notes. cx_Oracle has a major new release under a new name and homepage python-oracledb. New projects should install python-oracledb instead of cx_Oracle.


1 Answers

You can try this (after the steps that you already report in your question)

  1. Check if the installation in PyDev is ok (besides showing an error marker for import cx_Oracle)

    import cx_Oracle
    
    conn = cx_Oracle.connect('hr/hr@pdborcl')
    cur = conn.cursor()
    cur.execute('select 13 from dual')
    for r in cur.fetchall():
        print(r)
    

    If this works, and prints (13,) the installation is correct. Likely some part of completion could work as well. In addition, Shift+Click on cx_Oracle should report The definition of ... was found at ....

  2. Go to Windows > Preferences > PyDev > Interpreters > Python Interpreter and on the tab Forced builtins add cx_Oracle

    After rebuilding the project, the error markers on the import should go away. (In the little test program I just did a trivial edit and saved.)

For the record:

Eclipse Version: 4.6.0 (Neon)
PyDev Version: 5.2.0
Python: 3.5.2 (from a virtualenv)
like image 172
M. Wymann Avatar answered Nov 15 '22 05:11

M. Wymann