开发者社区> 问答> 正文

mac 上,import cx_Oracle 报错:Symbol not fou?报错

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

bogon:~ lichunyan$ python 

<p style="font-size:11px;font-family:Menlo;">
	Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) 
</p>
<p style="font-size:11px;font-family:Menlo;">
	[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
</p>
<p style="font-size:11px;font-family:Menlo;">
	Type "help", "copyright", "credits" or "license" for more information.
</p>
<p style="font-size:11px;font-family:Menlo;">
	>>> import cx_Oracle
</p>
<p style="font-size:11px;font-family:Menlo;">
	Traceback (most recent call last):
</p>
<p style="font-size:11px;font-family:Menlo;">
	  File "<stdin>", line 1, in <module>
</p>
<p style="font-size:11px;font-family:Menlo;">
	ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so, 2): Symbol not found: _OCIAttrGet
</p>
<p style="font-size:11px;font-family:Menlo;">
	  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so
</p>
<p style="font-size:11px;font-family:Menlo;">
	  Expected in: flat namespace
</p>
<p style="font-size:11px;font-family:Menlo;">
	 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle.so
</p>
<div>
	<br>
</div>

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

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

<p style="font-size:11px;font-family:Menlo;">
	bogon:~ lichunyan$ source ~/.bash_profile
</p>
<p style="font-size:11px;font-family:Menlo;">
	bogon:~ lichunyan$ echo $ORACLE_HOME
</p>
<p style="font-size:11px;font-family:Menlo;">
	/Users/lichunyan/oracle/instantclient_11_2
</p>
<p style="font-size:11px;font-family:Menlo;">
	bogon:~ lichunyan$ vi ~/.bash_profile
</p>
<p style="font-size:11px;font-family:Menlo;">
	export ORACLE_HOME=/Users/lichunyan/oracle/instantclient_11_2
</p>
<p style="font-size:11px;font-family:Menlo;">
	export DYLD_LIBRARY_PATH=$ORACLE_HOME
</p>
<p style="font-size:11px;font-family:Menlo;">
	export LD_LIBRARY_PATH=$ORACLE_HOME
</p>
<p style="font-size:11px;font-family:Menlo;">
	export DYLD_LIBRARY_PATH
</p>
<p style="font-size:11px;font-family:Menlo;">
	TNS_ADMIN=/Users/lichunyan/oracle/tns
</p>
<p style="font-size:11px;font-family:Menlo;">
	export TNS_ADMIN
</p>
<p style="font-size:11px;font-family:Menlo;">
	export NLS_LANG="AMERICAN_AMERICA.UTF8"
</p>
<p style="font-size:11px;font-family:Menlo;">
	export LDFLAGS="-arch x86_64"
</p>
<p style="font-size:11px;font-family:Menlo;">
	#
</p>
<p style="font-size:11px;font-family:Menlo;">
	# Your previous /Users/lichunyan/.bash_profile file was backed up as /Users/lichunyan/.bash_profile.macports-saved_2016-04-20_at_14:15:52
</p>
<p style="font-size:11px;font-family:Menlo;">
	##
</p>
<p style="font-size:11px;font-family:Menlo;">
	# MacPorts Installer addition on 2016-04-20_at_14:15:52: adding an appropriate PATH variable for use with MacPorts.
</p>
<p style="font-size:11px;font-family:Menlo;">
	export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
</p>
<p style="font-size:11px;font-family:Menlo;">
	# Finished adapting your PATH environment variable for use with MacPorts.
</p>
<p style="font-size:11px;font-family:Menlo;">
	# Setting PATH for Python 2.7
</p>
<p style="font-size:11px;font-family:Menlo;">
	# The orginal version is saved in .bash_profile.pysave
</p>
<p style="font-size:11px;font-family:Menlo;">
	PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
</p>
<p style="font-size:11px;font-family:Menlo;">
	export PATH<span style="color:#5E34FF;">                                                                               </span>
</p>
<p style="font-size:11px;font-family:Menlo;">
	<span style="color:#5E34FF;"><br>

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

展开
收起
爱吃鱼的程序员 2020-06-09 15:42:43 672 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

    2020-06-09 15:42:59
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_樊文凯_ORACLE数据库和应用异构迁移最佳实践 立即下载
PostgresChina2018_王帅_从Oracle到PostgreSQL的数据迁移 立即下载
Oracle云上最佳实践 立即下载

相关镜像