我有一个非常奇怪的问题,我无法理解并希望你们都可以。按照this link的步骤,我已经安装了Oracle即时客户端和cx_Oracle,我可以在Python中导入cx_Oracle没问题。我已经在virtualenv中完成了所有这些。
问题在于我尝试
./manage.py runserver
我得到了
raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module:
dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so,
2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found
当然,这正是cx_Oracle.so文件所在的位置。
所以我搜索并找到this SO question,但运行Ruby脚本实际上在python中破坏了我的cx_Oracle导入,并没有解决django问题。相反,它会在下面给出错误,无论是直接在Python中还是在django环境中。我该如何解决?我需要能够在django中导入cx_Oracle!谢谢!
ImportError: dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so,
2): Library not loaded: /Users/Shawn/Oracle/instantclient_11_2/
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: no suitable image found. Did find:
/Users/Shawn/Oracle/instantclient_11_2/: not a file
/Users/Shawn/Oracle/instantclient_11_2/: not a file
/usr/local/lib/: not a file
/usr/lib/: not a file
编辑: 我擦拭并重新创造了我的虚拟现实。然后我意识到我没有在与即时客户端可执行文件相同的目录中运行它,然后重试了Ruby脚本。它从
运行并更新@executable_path/...
to
/Users/shawn/Oracle/...
我尝试在我的virtualenv python中导入cx_Oracle,这次它起作用而不是抛出错误。不幸的是,试图运行我的django服务器仍然爆炸说
Raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module: dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: libclntsh.dylib.11.1
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found
我无法理解为什么python可以导入它但django不能导入它。
答案 0 :(得分:0)
按照本页底部的说明安装Oracle即时客户端:
http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
您可能还需要设置DYLD_LIBRARY_PATH或使用otool -L和install_name_tool进行调整。