简体   繁体   English

在Centos 6上安装cx_Oracle

[英]installing cx_Oracle on Centos 6

I'm having a heck of a time trying to get cx_Oracle installed. 我有一点时间试图安装cx_Oracle。

I've tried various versions of the Oracle libraries. 我尝试过各种版本的Oracle库。 The ones I get closest with the 32-bit 11.1 libraries 我最接近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

I have the environment variables set to: [~]# set | 我将环境变量设置为:[〜] #set | grep -i oracle 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: grep -i oracle 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:

and when I run pipinstall, it fails to find the include files: 当我运行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

Here's the rpms that have been installed: 这是已经安装的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
[~]#

I also tried to install the cx_Oracle rpm: cx_Oracle-5.1.2-11g-py33-1.x86_64.rpm and that didn't work either. 我也尝试安装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

But after that install, it's still not recognized. 但在安装之后,它仍然无法识别。

[~]# 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'
>>>

I wrote this script about one years ago for install cx_Oracle in debian: 我在大约一年前编写了这个脚本,用于在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

I also encountered this situation. 我也遇到过这种情况。 The issue was a permissions issue due to installations requiring "sudo" permissions for "pip install". 由于安装需要“pip install”的“sudo”权限,因此问题是权限问题。

NOTE: I'm using oracle linux 6, so mileage may differ 注意:我正在使用oracle linux 6,因此里程可能会有所不同

Here is the directory listing where cx_Oracle.so was sent following build so you can see the default permissions (compare to cx_Freeze, for example, which has world access): 以下是在构建之后发送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

I could identify this issue with the following, which executes python as root, and then "import cx_Oracle" works: 我可以用以下内容识别这个问题,它以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
>>> 

So... I hit it over the head with a hammer... and let my user own it all (which is the wrong solution, admittedly, and may have later fallout. - I would love to hear the right way to let my vagrant user "pip install" 所以......我用锤子把头撞到头上......然后让我的用户拥有它(这是错误的解决方案,不可否认,可能会有后来的问题。 - 我很想听到正确的方式让我的流浪者用户“pip install”

Hope this help, J 希望这有帮助,J

Nothing I did could resolve the library issue. 我所做的一切都无法解决图书馆问题。 While Farhadix's suggestion was helpful, I could not get past this error when doing an "import cx_Oracle": 虽然Farhadix的建议很有帮助,但在执行“import cx_Oracle”时我无法解决此错误:

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

I ended up removing the cx_Oracle package (rpm -e cx_Oracle-5.1.2-1.x86_64) and building the module from source following instructions from here . 我最终删除了cx_Oracle包(rpm -e cx_Oracle-5.1.2-1.x86_64)并按照此处的说明从源代码构建模块。 That was what I needed to do to get the extension to work on CentOS 6.4 with python 3.3. 这就是我需要做的就是使用python 3.3使扩展能够在CentOS 6.4上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM