views:

353

answers:

1

I've successfully installed the latest version of PyDev in my Eclipse (3.5.1) under OS X 10.6.3, with python 2.6.1
I have troubles in making the libraries I have installed work.
For example, I'm trying to use the cx_Oracle library, which is perfectly working if called from the python interpeter of from simple scripts made with some text editor.
But I cant make it work inside Eclipse: I have this small piece of code:

import cx_Oracle
conn = cx_Oracle.connect(CONN_STRING)
sql = "select field from mytable"
cursor = conn.cursor()
cursor.execute(sql)
for row in cursor:
    field = row[0]
    print field

If I execute it from Eclipse, I get the following error:

import cx_Oracle
  File "build/bdist.macosx-10.6-universal/egg/cx_Oracle.py", line 7, in <module>
  File "build/bdist.macosx-10.6-universal/egg/cx_Oracle.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so, 2): Library not loaded: /b/227/rdbms/lib/libclntsh.dylib.10.1
  Referenced from: /Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so
  Reason: no suitable image found.  Did find:
    /Users/dave/lib/libclntsh.dylib.10.1: mach-o, but wrong architecture

Same snippet works perfectly from the python shell

I have configured the interpeter in Eclipse in preferences -> PyDev --> Interpreter - Python, using the Auto Config option and selecting all the libs found.

What am I doing wrong here?

Edit: launching

file /Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so

from the command line tells this:

/Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so: Mach-O universal binary with 3 architectures
/Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so (for architecture i386):  Mach-O bundle i386
/Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so (for architecture ppc7400):   Mach-O bundle ppc
/Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so (for architecture x86_64):    Mach-O 64-bit bundle x86_64
A: 

Don't know if you have fixed this yet, but from the comments it looks like you have a 32 / 64 bit issue going on somewhere along the line.

cx_Oracle.so is a universal binary with PPC, 32 and 64 bit Intel versions inside, but from your comment your result for libclntsh.dylib.10.1 differs from mine

file libclntsh.dylib.10.1
libclntsh.dylib.10.1: Mach-O 64-bit dynamically linked shared library x86_64

while I get the same result as you if I run the same command against the 32 bit client (which I keep in a separate directory)

file libclntsh.dylib.10.1
libclntsh.dylib.10.1: Mach-O dynamically linked shared library i386

I am guessing that when running from the command line it is either using a different path and picking up the appropriate libclntsh, or that running through Eclipse is causing it to run in the opposite mode from command line.

Solution - download both 32 and 64 bit versions of Instant Client from Oracle, but in differently named directories, and control which one is used by using links.

If you are feeling brave, you could do the job Oracle failed to do and merge the two dylib into a Universal binary.

http://developer.apple.com/mac/library/technotes/tn2005/tn2137.html#TNTAG3
JulesLt