Skip to content

Instantly share code, notes, and snippets.

@rmoff
Created June 25, 2015 12:45
Show Gist options
  • Select an option

  • Save rmoff/cadd24cd3b1bf44357b2 to your computer and use it in GitHub Desktop.

Select an option

Save rmoff/cadd24cd3b1bf44357b2 to your computer and use it in GitHub Desktop.
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
[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.

@TheGuitarLord
Copy link

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_Oracle and that preserved the env variables for sudo. -E preserves the environment variables in EC2 AWS. Thumbs up, man thanks!

@isaacdchan
Copy link

Do you mind elaborating what you mean when you "ran as the oracle user"? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment