我已经在OS X 10.6.3下的Eclipse(3.5.1)中成功安装了最新版本的PyDev,使用python 2.6.1
我在安装我已安装的库时遇到了麻烦.
例如,我正在尝试使用cx_Oracle库,如果从使用某些文本编辑器创建的简单脚本的python interpeter调用,则该库非常有效.
但我不能让它在Eclipse中运行:我有一小段代码:
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
如果我从Eclipse执行它,我会收到以下错误:
import cx_Oracle File "build/bdist.macosx-10.6-universal/egg/cx_Oracle.py", line 7, inFile "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
相同的代码段完全可以从python shell中运行
我在偏好中配置了Eclipse中的interpeter - > PyDev - > Interpreter - Python,使用Auto Config选项并选择找到的所有lib.
我在这做错了什么?
编辑:启动
file /Users/dave/.python-eggs/cx_Oracle-5.0.3-py2.6-macosx-10.6-universal.egg-tmp/cx_Oracle.so
从命令行告诉:
/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
小智.. 5
在eclipse中,在'PyDev',Interpreter - Python(或者你正在使用的)下设置以下'环境变量'.
ORACLE_HOME = [您的安装路径]/instantclient_10_2
LD_LIBRARY_PATH = $ ORACLE_HOME
DYLD_LIBRARY_PATH = $ ORACLE_HOME
它对我有用.
在eclipse中,在'PyDev',Interpreter - Python(或者你正在使用的)下设置以下'环境变量'.
ORACLE_HOME = [您的安装路径]/instantclient_10_2
LD_LIBRARY_PATH = $ ORACLE_HOME
DYLD_LIBRARY_PATH = $ ORACLE_HOME
它对我有用.