nyc*_*nik 6 python macos python-2.7
无法让cx_Oracle与Python版本2.7/mac os 10.7.2(Lion)一起使用
另一件事:我已经安装了oracle 32位,不确定这是否正确.
Traceback (most recent call last):
File "reader.py", line 9, in <module>
import cx_Oracle
File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so, 2): Symbol not found: _OCIAttrGet
Referenced from: /Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so
Expected in: flat namespace
in /Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so
Run Code Online (Sandbox Code Playgroud)
他们的关键问题似乎无法定位_OCIAttGet
,我认为这意味着它无法找到lib文件或其他东西.
发现在网络上,有人在谈论DYLD_LIBRARY_PATH
,但我的设置,但他在cxoracle.cfg
文件中提到,我找不到,这是我的问题?
编辑
尝试使用32位模式python运行它后,我看到一个不同的错误.
Traceback (most recent call last):
File "reader.py", line 9, in <module>
import cx_Oracle
File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 3, in __bootstrap__
ImportError: No module named pkg_resources
Run Code Online (Sandbox Code Playgroud)
第二次编辑
实际上无论我安装什么,它都不是正确的版本.. 32位版本
ld: warning: ignoring file /opt/oracle/instantclient10_2/libclntsh.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Run Code Online (Sandbox Code Playgroud)
64位版本:
ld: warning: ignoring file /opt/oracle/instantclient10_2/libclntsh.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
Run Code Online (Sandbox Code Playgroud)
我打算尝试11g,但只有64位版本.
小智 6
要编译cx_Oracle以便在OS X上工作需要配置一些东西.重要的是:
使用仅剥离为32位的python解释器创建virtualenv.在virtualenv bin目录($WORKON_HOME/*name_of_virtualenv*/bin
)中:
% mv python python.fat
% lipo python.fat -remove x86_64 -output python
Run Code Online (Sandbox Code Playgroud)尽管Python现在很薄,但它的配置并非如此,我们需要使用一个模糊的环境变量来强制使用distutils将会提取的东西:
ARCHFLAGS="-arch i386" pip install cx_Oracle
Run Code Online (Sandbox Code Playgroud)如果您使用 Apple 提供的 Python 2.7,它会更喜欢在 64 位模式下运行,如果您安装了仅 32 位的 Oracle 库,这将是一个问题。您可以尝试通过以下方式启动 Python 来强制其以 32 位模式运行:
arch -i386 python2.7
Run Code Online (Sandbox Code Playgroud)
如果您总是小心地通过 启动 python ,您还可以使用 Apple 的Python 页面/usr/bin/python
中描述的方法之一,即设置环境变量或通过 来设置永久默认值。man
VERSIONER_PYTHON_PREFER_32_BIT
defaults
归档时间: |
|
查看次数: |
12243 次 |
最近记录: |