web-dev-qa-db-ja.com

cx_Oracle:distutils.errors.DistutilsSetupError:Oracleインクルードファイルが見つかりません

LinuxでPython 2.5(Linux 2.6.18-371.1.2.el5 i686)の場合はcx_Oracleをインストールする必要があります。Oracleクライアント10.2.0.4をインストールしました。

次のことを試しました。1. cx_Oracle tar.gzからhttp://sourceforge.net/projects/cx-Oracle/files/をダウンロードします。リストされているバージョンのどれがpython 2.5およびOracleクライアント10.2.0.4に適しているかわかりません。cx_Oracle-5.1.tar.gzを試してください。 python setup.py install。エラーが発生しました:

Traceback (most recent call last):
File "setup.py", line 187, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files

.bash_profileでOracleパスを設定しました:

export Oracle_HOME=/usr/Oracle/10.2.0.4/client
export PATH=$Oracle_HOME/bin
export LD_LIBRARY_PATH=$Oracle_HOME/lib

このようなエラーをどのように修正しますか、cx_Oracle tarの別のバージョンが必要なのでしょうか?

  1. Pip install cx_Oracleを実行します。エラーが発生しました:

Cx-Oracleのダウンロード/展開

Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement cx-Oracle
No distributions at all found for cx-Oracle

誰かが私に正しい解決策をアドバイスできますか?

更新応答の提案の後、次のエラーが表示されました。

...
cx_Oracle.c:496: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from  pointer without a cast
cx_Oracle.c:497: error: âOCI_UCBTYPE_EXITâ undeclared (first use in this function)
cx_Oracle.c:497: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
cx_Oracle.c:498: error: âOCI_UCBTYPE_REPLACEâ undeclared (first use in this function)
cx_Oracle.c:498: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
error: command 'gcc' failed with exit status 1
20
khris

Setup.pyを実行すると、Oracle_HOMEにあるこれらのフォルダーがチェックされます。

possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
        "sdk/include"]

また、インスタントクライアントは、oci_hなどのインクルードファイルを/ usr/include/Oracle // clientに配置する場合があります。Oracle_HOMEに「include」ディレクトリがない場合は、シンボリックリンクを作成します。

Sudo ln -s /usr/include/Oracle/11.2/client $Oracle_HOME/include

Client SDK が欠落しているようです

14
fn.
  1. インストールOracle_client_basic

    Oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
    
  2. Pip installを使用する

    python -m pip install cx_Oracle
    
  3. Ldconfigの追加

    1. クライアントの場所を見つけます。例:/u01/app/Oracle/product/11.2.0/client_1/lib
    2. vi /etc/ld.so.conf.d/Oracle.conf

      この場所を追加します:

      /u01/app/Oracle/product/11.2.0/client_1/lib
      
    3. ldconfig
  4. import cx_Oracle
1
james.peng

OSにインスタントクライアントSDKをインストールしてください。

http://www.Oracle.com/technetwork/database/features/instant-client/index-097480.html

1
etlds

パスにクライアントSDKが存在することを確認してください。

また、これを.bash_rcに追加する必要がありました

export DYLD_LIBRARY_PATH=$Oracle_HOME

これに加えて、Python 2.7にはPython.hが付属していません。Python.hはデフォルトでPython 3.4にあります。したがって、python-開発パッケージ

yum install python-devel

これで問題は解決するはずです。

0
ARK