Error cx_Oracle pip: oci.h: No such file or directory

I lost it a bit. I also tried installing the older version of cx_Oracle that I installed in a separate virtualenv, but it also fails in the same place with the same error message.

$ pip install cx_Oracle (...) cx_Oracle.c:10:17: error: oci.h: No such file or directory cx_Oracle.c:11:18: error: orid.h: No such file or directory cx_Oracle.c:12:16: error: xa.h: No such file or directory error: command 'gcc' failed with exit status 1 (...) ---------------------------------------- Cleaning up... Command /R/.virtualenv/myenv/bin/python -c "import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle Traceback (most recent call last): File "/R/.virtualenv/myenv/bin/pip", line 11, in <module> sys.exit(main()) File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main return command.main(cmd_args) File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main text = '\n'.join(complete_log) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128) 

full error log

+6
source share
4 answers

I encountered a similar error trying to install install cx_oracle even after installing the instant Oracle client and after installing $ ORACLE_HOME and $ LD_LIBRARY_PATH to include the client path.

It sounds as if you installed Instant Client, but not the Instant Client SDK. The SDK is a separate download / install, and cx_oracle seems to need both, since the missing included ones ('oci.h' and everyone else) are located in the SDK.

If you have not been there, you can find the Oracle Instant Client / SDK download pages here:

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

Assuming you have already downloaded and installed a client that matches your platform, for example. this:

oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip

you will also need to download and install the appropriate SDK, for example. this:

oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip

While the SDK is installed somewhere on the paths in ORACLE_HOME and LD_LIBRARY_PATH, you must enable inclusions.

+12
source

The problem is that the SDK is missing as indicated by bschulz. I was able to fix the problem by following these steps:

  • Download and install / unpack "instantclient-basic" and "instantclient-sdk" in $ ORACLE_HOME.

    You can get them from here.

  • Install /etc/environment

     export ORACLE_HOME=/opt/oracle/instantclient_12_2 export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2 cd $ORACLE_HOME unzip /sdk/ottclasses.zip cp -R ./sdk/* . cp -R ./sdk/include/* . ln -s libclntsh.so.12.1 libclntsh.so ln -s libocci.so.12.1 libocci.so 

Now run pip install cx_Oracle==5.3

I followed them and he successfully installed 5.3 for me.

You may need to install some additional dependencies listed below in the Package Documentation that you must download / install.

+2
source

As bschulz explains, this problem is usually resolved using the environment variables ORACLE_HOME and LD_LIBRARY_PATH to ensure that gcc can access header files. In my case, this did not solve the problem, but the error check was given to me by a hint to solve the problem.

Executing pip cx_Oracle installation showed this error:

 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1 cx_Oracle.c:10:17: error: oci.h: No such file or directory cx_Oracle.c:11:18: error: orid.h: No such file or directory cx_Oracle.c:27:2: error: #error Unsupported version of OCI. 

Search for -I flag in man gcc:

 -I dir Add the directory dir to the list of directories to be searched for header files. .... 

So the problem was with these flag values:

 -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 

I cannot say why the -I flag was set for these values, but an easy way to make it work is to change the flag that passes the correct values ​​from the pip command line:

  pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include" 

Thus, the new -I value is sent to gcc, and the installation ends correctly.

0
source

From cx_Oracle 6:

  • Binary wheels are available on PyPI, so many people don’t need to compile
  • if you need to compile, Oracle header files are not necessary, and you do not need / do not need to set ORACLE_HOME when using Oracle Instant Client.

In cx_Oracle 5.2 and 5.3, if you use RPM Instant Instant, you do not need to set ORACLE_HOME during installation, and you do not need to set LD_LIBRARY_PATH at run time. If you are using Instant Client zips (or a real DBA ORACLE_HOME installation), you can set FORCE_RPATH = 1 before installing cx_Oracle. If you do this, you will not need to set LD_LIBRARY_PATH at run time. This function has been in cx_Oracle for several versions.

0
source

Source: https://habr.com/ru/post/975405/


All Articles