mac 上,import cx_Oracle 报错:Symbol not found: _OCIAttrGet

kaxifa 发布于 2016/04/21 17:53
阅读 663
收藏 0

最近由于项目需要,需要安装cx_Oracle,我按照教程:http://joelvasallo.com/?p=276 成功安装了cx_Oracle,但是在import cx_Oracle时报错:

bogon:~ lichunyan$ python 

Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) 

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import cx_Oracle

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so, 2): Symbol not found: _OCIAttrGet

  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so

  Expected in: flat namespace

 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so


我的Mac系统是64位的, 自己安装的python也是64位的,下载的instant client也是64位的,sdk也是64位的。。  ~/.bash_profile 文件内容如下:

Last login: Thu Apr 21 17:37:24 on console

bogon:~ lichunyan$ source ~/.bash_profile

bogon:~ lichunyan$ echo $ORACLE_HOME

/Users/lichunyan/oracle/instantclient_11_2

bogon:~ lichunyan$ vi ~/.bash_profile

export ORACLE_HOME=/Users/lichunyan/oracle/instantclient_11_2

export DYLD_LIBRARY_PATH=$ORACLE_HOME

export LD_LIBRARY_PATH=$ORACLE_HOME

export DYLD_LIBRARY_PATH

TNS_ADMIN=/Users/lichunyan/oracle/tns

export TNS_ADMIN

export NLS_LANG="AMERICAN_AMERICA.UTF8"

export LDFLAGS="-arch x86_64"

#

# Your previous /Users/lichunyan/.bash_profile file was backed up as /Users/lichunyan/.bash_profile.macports-saved_2016-04-20_at_14:15:52

##

# MacPorts Installer addition on 2016-04-20_at_14:15:52: adding an appropriate PATH variable for use with MacPorts.

export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

# Finished adapting your PATH environment variable for use with MacPorts.

# Setting PATH for Python 2.7

# The orginal version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

export PATH                                                                               


有人遇到过这种问题吗?是怎么解决的呢?我已经跟这个问题纠缠了2天了,但无任何进展,愁死宝宝了

加载中
0
zwcloud
zwcloud
http://stackoverflow.com/questions/8158536/importing-cx-oracle-python-with-macosx
0
C
CHNnoodle
楼主问题解决了吗? 我也遇到了呀,我用的mac自带的python,好像无法切换到32位的python呀
kaxifa
kaxifa
我已经解决了呢,我的Mac环境其实已经是OK的了,只是我用的pycharm,这个需要另外再在其解释器里添加Oracle的那几个环境变量,添加完就OK了。
返回顶部
顶部