您好 - 我已在 Mac OS X Yosemite 10.10 上成功安装了 cx_Oracle,并且我可以在终端中使用 Python 2.7.11 通过 Mac 终端查询我的 Oracle 数据库。
唯一的问题是 IDLE shell 应用程序无法导入 cx_Oracle 并显示以下错误:
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cx_Oracle
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found
以下是我在 Mac 终端中看到的内容(然后我可以继续成功查询数据库):
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
IDLE 不允许导入 cx_Oracle,我缺少什么?
最佳答案
不要从固定图标运行 IDLE,而是使用 python -midlelib.idle 运行它。 (对于 3.x,不需要 .idle
。)我不知道为什么在这种情况下效果更好,但我知道从图标运行有时会隐藏所需的信息,例如将运行,当前 python 将运行的工作目录,启动参数和一些错误消息。
关于python - IDLE shell 无法找到 cx_Oracle 的镜像(原因 : image not found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35258901/