cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files

孤者浪人 提交于 2019-12-03 09:53:35

When you run setup.py it will check for any of these folders on your ORACLE_HOME.

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

Also the instant client sometimes places the include files, such as oci.h, in /usr/include/oracle//client, if there is no 'include' directory under ORACLE_HOME create a symbolic link to it.

sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include

Looks like you're missing the Client SDK

Make sure you install the instant client sdk for you OS.

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

  1. Install oracle_client_basic

    oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
    
  2. Using pip install

    python -m pip install cx_Oracle
    
  3. Adding ldconfig

    1. Find your client location, for example: /u01/app/oracle/product/11.2.0/client_1/lib
    2. vi /etc/ld.so.conf.d/oracle.conf

      Add this location into it:

      /u01/app/oracle/product/11.2.0/client_1/lib
      
    3. ldconfig
  4. import cx_oracle

Make sure that you've a client sdk present in your path.

Also I had to do add this to my .bash_rc

export DYLD_LIBRARY_PATH=$ORACLE_HOME

In addition to this, Python 2.7 does not come with Python.h which is available by default in Python 3.4. So I would also suggest to install python-devel package

yum install python-devel

That should resolve the issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!