"error: cannot locate an Oracle software installation" When trying to install cx_Oracle

StackOverflow https://stackoverflow.com/questions/13234196

  •  27-11-2021
  •  | 
  •  

Pregunta

Newbie here trying to use python to do some database analysis. I keep getting the error: "error: cannot locate an Oracle software installation" When installing CX_oracle (via easy_install).

The problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case.

Any suggestions?

¿Fue útil?

Solución

Don't use easy_install or pip, they don't really work very well for installing cx_Oracle since there are a number of environmental dependencies that the install scripts don't set up automatically. You need to get an oracle client driver, the quickest of which to find is the instantclient. Then point your ORACLE_HOME and PATH at the install location for the drivers, and install cx_Oracle itself. You should be good to go after that.

see: easy_install cx_Oracle (python package) on Windows

The question is about windows, but the answer includes info on *nix.

Otros consejos

Install Oracle Client

  1. Download Oracle Client: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

    Example: oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

  2. Install Alien:

    sudo apt-get install alien
    
  3. install the RPM in the Ubuntu system:

    sudo alien -i oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm`
    
  4. Add to environment variables

    vim ~/.bashrc
    export ORACLE_HOME=/usr/lib/oracle/12.2/client64/lib/
    export LD_RUN_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_RUN_PATH
    source ~/.bashrc
    sudo ln -s /usr/lib/oracle/12.2/client64 $ORACLE_HOME/include`
    

Finally

pip install cx-Oracle

I installed cx_Oracle, but I also had to install an Oracle client to use it (the cx_Oracle module is just a common and pythonic way to interface with the Oracle client in Python).

So you have to set the variable ORACLE_HOME to your Oracle client folder (on Unix: via a shell, for instance; on Windows: create a new variable if it does not exist in the Environment variables of the Configuration Panel). Your folder $ORACLE_HOME/network/admin (%ORACLE_HOME%\network\admin on Windows) is the place where you would place your tnsnames.ora file.

I got this message when I was trying to install the 32 bit version while having the 64bit Oracle client installed.

What worked for me: reinstalled python with 64 bit (had 32 for some reason), installed cx_Oracle (64bit version) with the Windows installer and it worked perfectly.

I followed this link instructions and it worked for me.

Download Oracle Basic/SDK from :

Oracle Instant Client Basic

Oracle Instant Client SDK

mkdir /Users/<username_here>/oracle
mv /Users/<username_here>/Downloads/instantclient-*         
/Users/<username_here>/oracle
cd /Users/<username_here>/oracle
unzip instantclient-basic-macos.x64-11.2.0.3.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.3.0.zip
cd instantclient_11_2/sdk
unzip ottclasses.zip
cd ..
cp -R ./sdk/* .
cp -R ./sdk/include/* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
vim ~/.bash_profile (and below to bash_profile)

  export ORACLE_HOME=/Users/<username_here>/oracle/instantclient_11_2
  export DYLD_LIBRARY_PATH=$ORACLE_HOME
  export LD_LIBRARY_PATH=$ORACLE_HOME

pip install cx_Oracle

After this if you get an error like:

1): Library not loaded:
/ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1

you have to :

sudo mkdir -p /ade/b/3071542110/oracle/rdbms/lib/
cd /ade/b/3071542110/oracle/rdbms/lib/
sudo ln -s /opt/oracle/instantclient/libclntsh.dylib.11.1 libclntsh.dylib.11.1

Tip for Ubuntu users

After configuring .bashrc environment variables, like it was explained in other answers, don't forget to reload your terminal window, typing $SHELL.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top