dmvianna dmvianna - 1 year ago 373
Python Question

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

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/';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>
File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/", line 185, in main
return command.main(cmd_args)
File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/", 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

Answer Source

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:

Assuming that you already downloaded and installed the client appropriate to your platform, e.g. this one:

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download