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-b开发者_运维技巧it bundle x86_64
In eclipse, set the following ‘environment variables’ under ‘PyDev’, Interpreter – Python (or which ever you are using).
- ORACLE_HOME=[your installation path]/instantclient_10_2
- LD_LIBRARY_PATH=$ORACLE_HOME
- DYLD_LIBRARY_PATH=$ORACLE_HOME
It worked for me.
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
I had a similar issue with cx_Oracle and Eclipse: Everything worked in Terminal, same no suitable image error
in Eclipse. This was definitely an binary compatibility issue (for me, it was 32- vs 64-bit).
JulesLt had the solution when he referenced the developer site. I used the lipo
option detailed in that document. It was remarkably easy. As we have developers using both 32-bit and 64-bit installations, we already had an instantclient built for each (no PPC machines here).
Assuming the sibling directories of instantclient_32
, instantclient_64
and instantclient_fat
—where instantclient_fat
is just a copy of either the 32- or 64-bit directory—the following should do the trick:
cd instantclient_32 ; for f in `ls *dylib* genezi sqlplus` ; do lipo -create $f ../instantclient_64/$f -output ../instantclient_fat/$f ; done
The above will overwrite the relevant executables in instantclient_fat
with the fat binaries. Once you have done this, build cx_Oracle
against this instantclient
library and voilà.
Thanks to JulesLt ... this solved a number of annoying issues.
精彩评论