简体   繁体   中英

can not import cx_oracle in OS X

I have successfully installed cx_oracle using pip, but when error

ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: libclntsh.dylib.11.1
Referenced from: /usr/local/lib/python2.7/site-packages/cx_Oracle.so
Reason: unsafe use of relative rpath libclntsh.dylib.11.1 in /usr/local/lib/python2.7/site-packages/cx_Oracle.so with restricted binary

occurred when I import cx_Oracle with ipython console. What's more another error

ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: libclntsh.dylib.11.1
Referenced from: /usr/local/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found

occurred when I using default python console.
It did not work in pycharm ide, either, I've spent much time working on this, anyone knows how to solve it? THX

Do you have the Oracle Instant Client and SDK installed?

If so, you have to export the library paths appropriately, depending on where you put your client. For example:

PATH=$PATH:/Library/Oracle/instantclient_11_2
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Library/Oracle/instantclient_11_2
CLASSPATH=$CLASSPATH:$ORACLE_HOME
TNS_ADMIN=/Library/Oracle/instantclient_11_2/network/admin

export TNS_ADMIN
export PATH
export DYLD_LIBRARY_PATH
export CLASSPATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM