Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_Oracle pip install fails: oci.h: No such file or directory

Tags:

python

pip

I'm a bit lost on this one. I also tried to install an older version of cx_Oracle, which I have installed in a separate virtualenv, but it also fails at 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

like image 842
dmvianna Avatar asked Sep 17 '14 08:09

dmvianna


1 Answers

I ran into a similar error trying to pip install cx_oracle, even after installing Oracle instant client, and after setting $ORACLE_HOME and $LD_LIBRARY_PATH to include the path to the client.

It sounds as if you might have installed the Instant Client, but not the Instant Client SDK. The SDK is a separate download/install, and cx_oracle appears to need both, as the missing includes ('oci.h' and all the rest) are located in the SDK.

If you haven't already 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 that you already downloaded and installed the client appropriate to your platform, e.g. this one:

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

you'll also need to download and install the corresponding SDK, e.g. this one:

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

As long as the SDK is installed somewhere on the paths in ORACLE_HOME and LD_LIBRARY_PATH, the includes should resolve.

like image 76
bschulz Avatar answered Sep 21 '22 03:09

bschulz