[oracle@obi11-01 instantclient_12_1]$ sudo pip install cx_Oracle
Downloading/unpacking cx-Oracle
Running setup.py egg_info for package cx-Oracle
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/cx-Oracle/setup.py", line 170, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/cx-Oracle/setup.py", line 170, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
The problem was running as sudo all of the environment variables (ORACLE_HOME etc) were not actually available in the context. As a hack I just chmod'd the target site-packages folder that pip was trying to write to, and ran as the oracle user, not sudo
Also make sure you have instant client basic and sdk.
This was SUPER helpful. I've been wrestling with trying to get cx_Oracle on an EC2 box all day and came across this, and sure enough sudo was not being passed ORACLE_HOME. Our fix was to run
sudo -E pip install cx_Oracleand that preserved the env variables for sudo. -E preserves the environment variables in EC2 AWS. Thumbs up, man thanks!