簡體   English   中英

在Centos 6上安裝cx_Oracle

[英]installing cx_Oracle on Centos 6

我有一點時間試圖安裝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

我將環境變量設置為:[〜] #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:

當我運行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'
>>>

我在大約一年前編寫了這個腳本,用於在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

我也遇到過這種情況。 由於安裝需要“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

我所做的一切都無法解決圖書館問題。 雖然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)並按照此處的說明從源代碼構建模塊。 這就是我需要做的就是使用python 3.3使擴展能夠在CentOS 6.4上運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM