8

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.

14
  • can you do import sys; print(sys.executable) in both consoles (anaconda and eclipse) to be sure your setting has an effect? Commented Sep 19, 2016 at 19:03
  • They both say C:\bin\anaconda3\python.exe. (I had no idea that PyDev had an interactive console---very neat. Thank for the tip.) Commented Sep 19, 2016 at 19:07
  • I didn't know either, but I guessed that existed :) Well, weird. Once imported, can you print(cx_Oracle.__file__) to see where it is located? Commented Sep 19, 2016 at 19:10
  • It says cx_Oracle is installed in C:\bin\anaconda3\lib\site-packages\cx_Oracle.cp35-win_amd64.pyd. Commented Sep 19, 2016 at 19:12
  • sorry to ask this but can you type import cx_Oracle in the pydev console (now that you know there's one), respecting the case, and see what happens (getting desperate here) Commented Sep 19, 2016 at 19:18

1 Answer 1

4
+50

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)
Sign up to request clarification or add additional context in comments.

8 Comments

On conn = cx_Oracle.connect('hr/hr@pdborcl') I get: cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified
@GarretWilson: You will need to replace the connection string with something that works on your system. The syntax is the same as the connection string for SQL*Plus. Format <user>/<password>@<tnsname>
But I don't need or want to connect to a database on this platform. I just want the links to show up without errors and be able to click on them to view source.
Sorry for the misunderstanding then: The first step just serves to confirm that the installation is correct. To remove the error marker: Step 2
@GarretWilson: Another thing: You will not be able to view the source, because the extension is not written in Python. The installed file is in fact a DLL (named PYD). Auto-completion works to some extent.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.