`
linkyou66
  • 浏览: 227915 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

cx-oracle 编译错误问题的解决

 
阅读更多
<p></p>
<p>提炼要点:</p>
<p>1.需要安装instantclient 主要包括</p>
<p>'instantclient-linux-basic</p>
<p>'instantclient-sdk-linux' </p>
<p>'instantclient-sdk-linux' 里边有个sdk的文件保护一些访问数据库的头文件,将它和'instantclient-linux-basic'合并成一个文件</p>
<p>如instantclient</p>
<p>2。设置环境变量</p>
<p>export ORACLE_HOME=[your installation path]/instantclient(按照实际情况设置)</p>
<p>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME<br>顺便PATH也设置一下</p>
<p>3</p>
<p>cd $ORACLE_HOME<br>ln -s libclntsh.so.x.x libclntsh.so</p>
<p>4.</p>
<p>python setup.py build<br>python setup.py install<br><br>官方安装文章如下</p>
<pre>Linux Build Hints
-----------------
(Tested on RedHat 4.x, Gentoo 2008.0, Ubuntu 8.x, and Debian 4.x)
These hints are based on using Oracle's instantclient_11_1.  It is necessary
to download both 'instantclient-linux-basic' and 'instantclient-sdk-linux' from
oracle.com in order to successfully compile. 

http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

Each compressed tarball needs to be extracted to the exact same location.
Uncompress and untar each file from the same location in order to achieve this
result. If placing into a system area such as /opt or /usr/local, make sure to
have the correct permissions for writing to these filesystems and/or
directories. It is advisable to use the same account from start to finish while
installing cx_Oracle in order not to clobber the pre-set environment variables
set below.

It is necessary to set environment variables ORACLE_HOME and LD_LIBRARY_PATH
inside $HOME/.profile in order for cx_Oracle to import properly after
installation and in order to build correctly. Using a text editor add the
settings below to $HOME/.profile making sure to change the location of your
actual installation path.

   Example ($HOME/.profile):
   -------------------------
   export ORACLE_HOME=[your installation path]/instantclient_11_1
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

To put these variables into the working shell env, either source .profile
(. $HOME/.profile) or execute each export statement above from a shell
individually to set these variables. If these are not added to $HOME/.profile
they will need to be manually set each time cx_Oracle is loaded into Python.

After both packages are untarred to there installation location a link needs
to be made inside the instantclient_11_1 directory. If you are using a
different version of the instant client simply adjust the link per the version
of libclntsh.so.

   Steps:
   ------
   cd $ORACLE_HOME
   ln -s libclntsh.so.x.x libclntsh.so

Continue to step: Building and Compilation.


OS X Build Hints
----------------
(Tested on Leopard 10.5.x)
The procedures for OS X are almost idential to Linux except for the package
names and a few environmental caveats. For OS X it is necessary to download
both 'instantclient-basic-macosx' and 'instantclient-sdk-macosx'. Download and
extract each file per the build hints for Linux.

For OS X it is necessary to set environment variables ORACLE_HOME,
LD_LIBRARY_PATH and DYLD_LIBRARY_PATH inside $HOME/.profile and start a new
shell before testing cx_Oracle. If .profile does not exist, simply create one
with a text editor and add the necessary path info to these variables.

   Example ($HOME/.profile):
   -------------------------
   export ORACLE_HOME=[your installation path]/instantclient_11_1
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
   export DYLD_LIBRARY_PATH=$ORACLE_HOME

The variables placed inside $HOME/.profile need to be set prior to building.
Therefore, source .profile (. $HOME/.profile) or execute each export statement
above from a shell individually to set these variables.  Not having
DYLD_LIBRARY_PATH set inside $HOME/.profile prior to building will cause a
compilation error regardless of being set in the current shell's env.

After both packages are untarred a link needs to be made inside the
instantclient_11_1 directory.  If you are using a different version of the
instant client simply adjust the link per the version of libclntsh.dylib.

   Steps:
   ------
   cd $ORACLE_HOME
   ln -s libclntsh.dylib.x.x libclntsh.dylib

Continue to step: Building and Compilation.


Building and Compilation
------------------------
Use the provided setup.py to build and install the module which makes use of
the distutils module. Note that on Windows, I have used mingw32
(http://www.mingw.org) and the module will not build with MSVC without
modification. The commands required to build and install the module are as
follows:

python setup.py build
python setup.py install


Testing (Post Installation Quick Test)
--------------------------------------
A very quick installation test can be performed from the command line using
the Python interpreter. Below is an example of how this done. After importing
cx_Oracle there should be a line containing only '&gt;&gt;&gt;' which indicates the
library successfully loaded.

    $ python
    Python 2.5.2 (r252:60911, Oct 25 2008, 19:37:28)
    [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    &gt;&gt;&gt; import cx_Oracle
    &gt;&gt;&gt;

</pre>
分享到:
评论

相关推荐

    php手册.chm,php手册

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    php帮助文档,php。chm,php必备的中文手册

    53. 编译问题 54. 使用 PHP 55. PHP 和 HTML 56. PHP 和 COM 57. PHP 和其它语言 58. 从 PHP/FI 2 移植到 PHP 3 59. 从 PHP 3 移植到 PHP 4 60. 从 PHP 4 移植到 PHP 5 61. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    PHP手册(带评论版-2008-03-14).part2.rar

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    PHP手册(带评论版-2008-03-14).part1.rar

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    PHP函数参考手册大全

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    中文版PHP使用手册

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    经典收藏最全php5.0查询手册

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    PHP5 开发手册 简体中文手册

    53. 编译问题 54. 使用 PHP 55. PHP 和 HTML 56. PHP 和 COM 57. PHP 和其它语言 58. 从 PHP/FI 2 移植到 PHP 3 59. 从 PHP 3 移植到 PHP 4 60. 从 PHP 4 移植到 PHP 5 61. 杂类问题 IX. 附录 A. PHP 及其相关工程的...

    php手册PHP5研究室编无乱码版本chm

    52. 编译问题 53. 使用 PHP 54. PHP 和 HTML 55. PHP 和 COM 56. PHP 和其它语言 57. 从 PHP/FI 2 移植到 PHP 3 58. 从 PHP 3 移植到 PHP 4 59. 从 PHP 4 移植到 PHP 5 60. 杂类问题 IX. 附录 A. PHP 及其...

    PHP官方手册中文版

    64. 编译问题 65. 使用 PHP 66. PHP 和 HTML 67. PHP 和 COM 68. PHP 和其它语言 69. 从 PHP/FI 2 移植到 PHP 3 70. 从 PHP 3 移植到 PHP 4 71. 从 PHP 4 移植到 PHP 5 72. 杂类问题 IX. 附录 A. PHP ...

    PHP手册2007整合中文版

    64. 编译问题 65. 使用 PHP 66. PHP 和 HTML 67. PHP 和 COM 68. PHP 和其它语言 69. 从 PHP/FI 2 移植到 PHP 3 70. 从 PHP 3 移植到 PHP 4 71. 从 PHP 4 移植到 PHP 5 72. 杂类问题 IX. 附录 A. PHP 及其相关工程...

Global site tag (gtag.js) - Google Analytics