【问题标题】:installing cx_Oracle on Centos 6在 Centos 6 上安装 cx_Oracle
【发布时间】:2013-12-06 20:44:19
【问题描述】:

我正在尝试安装 cx_Oracle。

我尝试了各种版本的 Oracle 库。我最接近 32 位 11.1 库的那些

oracle-instantclient11.1-basic-11.1.0.7.0-1.i386.rpm
oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.i386.rpm

我将环境变量设置为: [~]# 设置 | grep -i 预言机 LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client/lib: ORACLE_HOME=/usr/lib/oracle/11.1/client/lib PATH=/usr/lib/oracle/11.1/client/lib:/home/sekingerg/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin: /bin:/usr/sbin:/usr/bin:/root/bin:/root/.rvm/bin SQLPATH=/usr/lib/oracle/11.1/client/lib:

当我运行 pipinstall 时,找不到包含文件:

[~]# pip install cx_Oracle
Downloading/unpacking cx-Oracle
  Running setup.py egg_info for package cx-Oracle
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/cx-Oracle/setup.py", line 180, in <module>
        raise DistutilsSetupError("cannot locate Oracle include files")
    distutils.errors.DistutilsSetupError: cannot locate Oracle include files
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build-root/cx-Oracle/setup.py", line 180, in <module>

    raise DistutilsSetupError("cannot locate Oracle include files")

distutils.errors.DistutilsSetupError: cannot locate Oracle include files

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-root/cx-Oracle
Storing complete log in /root/.pip/pip.log

这是已安装的 rpm:

[~]# rpm -qa | grep -i oracle
oracle-instantclient11.1-devel-11.1.0.7.0-1.i386
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.i386
oracle-instantclient11.1-basic-11.1.0.7.0-1.i386
[~]#

我还尝试安装 cx_Oracle rpm:cx_Oracle-5.1.2-11g-py33-1.x86_64.rpm,但也没有用。

[~]# rpm -ipv cx_Oracle-5.1.2-11g-py33-1.x86_64.rpm
Preparing packages for installation...
cx_Oracle-5.1.2-1

但在安装之后,它仍然无法识别。

[~]# python3
Python 3.3.2 (default, Nov 18 2013, 12:27:03) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cx_Oracle'
>>>

【问题讨论】:

    标签: python oracle cx-oracle


    【解决方案1】:

    大约一年前我为在 debian 中安装 cx_Oracle 编写了这个脚本:

    TMP_ORACLE_HOME="/usr/lib/oracle/11.2/client64"
    dpkg -i $PWD/libpython3.2_3.2.3-2_amd64.deb
    dpkg -i $PWD/libaio1_0.3.107-7_amd64.deb
    dpkg -i $PWD/oracle-instantclient11.2-basic_11.2.0.3.0-2_amd64.deb
    echo "$TMP_ORACLE_HOME/lib" > /etc/ld.so.conf.d/oracle.conf
    echo "export ORACLE_HOME=$TMP_ORACLE_HOME" > /etc/profile.d/oracle.sh
    dpkg -i $PWD/cx-oracle_5.1.2-2-py32_amd64.deb
    cd /usr/lib/python3.2
    mv site-packages dist-packages
    ln -s dist-packages site-packages
    ldconfig
    

    【讨论】:

    • 这确实有很大帮助,但我仍然无法正确加载模块。它找不到看起来像核心库的东西$ python3.3 Python 3.3.3 (default, Dec 2 2013, 16:16:04) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import cx_Oracle Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: libpython3.3m.so.1.0: cannot open shared object file: No such file or directory &gt;&gt;&gt; Any Ideas?
    【解决方案2】:

    我也遇到过这种情况。该问题是由于安装需要“pip install”的“sudo”权限而导致的权限问题。

    注意:我使用的是 oracle linux 6,所以里程可能会有所不同

    这是在构建后发送 cx_Oracle.so 的目录列表,因此您可以查看默认权限(例如,与 cx_Freeze 相比,它具有世界访问权限):

    [vagrant@oracle /]$ ll /usr/lib64/python2.6/site-packages
    total 4308
    drwxr-xr-x   5 root root   4096 Jan 17 09:48 cx_Freeze
    drwxr-x---   2 root root   4096 Jan 17 11:30 cx_Oracle-5.1.2-py2.6.egg-info
    -rwxr-x---   1 root root 351475 Jan 17 11:30 cx_Oracle.so
    

    我可以通过以下方式识别此问题,它以 root 身份执行 python,然后“import cx_Oracle”工作:

    [vagrant@oracle cx_OracleTools-8.0]$ sudo ORACLE_HOME=/usr/lib/oracle/11.2/client64 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/oracle/11.2/client64/lib python
    Python 2.6.6 (r266:84292, Oct 15 2013, 07:32:41) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cx_Oracle
    >>> 
    

    所以...我用锤子敲了它的头...让我的用户拥有它(诚然,这是错误的解决方案,并且可能会在以后产生后果。 - 我很想听听让我的流浪用户“pip install”的正确方法

    希望对您有所帮助, J

    【讨论】:

    【解决方案3】:

    我所做的一切都无法解决库问题。虽然 Farhadix 的建议很有帮助,但在执行“import cx_Oracle”时我无法克服这个错误:

    ImportError: libpython3.3m.so.1.0: cannot open shared object file: No such file or directory
    

    我最终删除了 cx_Oracle 包 (rpm -e cx_Oracle-5.1.2-1.x86_64) 并按照 here 的说明从源代码构建模块。这就是我需要做的,以使扩展在 CentOS 6.4 上与 python 3.3 一起工作。

    【讨论】:

      猜你喜欢
      • 2013-03-16
      • 2012-05-12
      • 2018-12-10
      • 2013-06-21
      • 2013-08-08
      • 2012-01-28
      • 2013-06-11
      • 2014-07-10
      • 2014-06-11
      相关资源
      最近更新 更多