Skip to content

Instantly share code, notes, and snippets.

@broqdev
Forked from thom-nic/cx_oracle_instructions.md
Last active April 9, 2016 00:04
Show Gist options
  • Select an option

  • Save broqdev/72342b22ff8ae2f250730c9244aa2484 to your computer and use it in GitHub Desktop.

Select an option

Save broqdev/72342b22ff8ae2f250730c9244aa2484 to your computer and use it in GitHub Desktop.

Revisions

  1. broqdev revised this gist Apr 9, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ If there is some permission problem during "python setup.py", don't use "sudo" b
    Run python and try to import cx_Oracle

    import cx_Oracle
    con = cx_Oracle.connect ('username/password@hostname:port/dbname')
    con = cx_Oracle.connect ('username/password@hostname:port/sid')
    print(con.version)
    con.close()

  2. broqdev revised this gist Apr 9, 2016. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -48,16 +48,22 @@ Install

    If there is some permission problem during "python setup.py", don't use "sudo" but try to use "chown" to get permission.

    ## Fix cx_Oracle.DatabaseError: ORA-21561: OID generation failed

    echo "127.0.0.1 $(hostname)" | sudo tee -a /etc/hosts

    ## Test
    Run python and try to import cx_Oracle

    python
    >>> import cx_Oracle
    import cx_Oracle
    con = cx_Oracle.connect ('username/password@hostname:port/dbname')
    print(con.version)
    con.close()

    You may get some UserWarning but that's fine. If there is some error then something is wrong.

    ## Refrences
    * https://gist.github.com/thom-nic/6011715
    * https://gist.github.com/kubo/8a45c653d06040c30135
    * https://sourceforge.net/p/cx-oracle/mailman/message/34534872/
    * https://github.com/joeferner/node-oracle/issues/47#issuecomment-38309484
  3. broqdev revised this gist Apr 8, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,10 @@ If there is some permission problem during "python setup.py", don't use "sudo" b
    Run python and try to import cx_Oracle

    python
    >>import cx_Oracle
    >>> import cx_Oracle

    You may get some UserWarning but that's fine. If there is some error then something is wrong.

    ## Refrences
    * https://gist.github.com/thom-nic/6011715
    * https://gist.github.com/kubo/8a45c653d06040c30135
  4. broqdev revised this gist Apr 8, 2016. 1 changed file with 8 additions and 10 deletions.
    18 changes: 8 additions & 10 deletions cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -13,18 +13,11 @@ Download the following files from [Oracle](http://www.oracle.com/technetwork/top
    * instantclient-basic-macos.x64-11.2.0.4.0.zip
    * instantclient-sdk-macos.x64-11.2.0.4.0.zip

    Download source code of cx_Oracle (https://sourceforge.net/projects/cx-oracle/files/5.1.2/)

    * cx_Oracle-5.1.2.tar.gz

    Create a directory `/usr/lib/share/oracle`
    Install

    export ORACLE_HOME=/usr/lib/share/oracle

    mkdir -p $ORACLE_HOME

    Unpack both files to that directory:

    cd $ORACLE_HOME
    tar -xzf instantclient-basic-macos.x64-11.2.0.4.0.zip
    tar -xzf instantclient-sdk-macos.x64-11.2.0.4.0.zip
    @@ -35,8 +28,13 @@ Unpack both files to that directory:
    curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
    ruby fix_oralib.rb --absolute-path

    ## Build and install cx_Oracle

    ## Install cx_Oracle
    Download source code of cx_Oracle (https://sourceforge.net/projects/cx-oracle/files/5.1.2/)

    * cx_Oracle-5.1.2.tar.gz

    Install

    export DYLD_LIBRARY_PATH=$ORACLE_HOME
    export LD_LIBRARY_PATH=$ORACLE_HOME
    export OCI_LIB_DIR=$ORACLE_HOME
  5. broqdev revised this gist Apr 8, 2016. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,10 @@ If there is some permission problem during "python setup.py", don't use "sudo" b
    Run python and try to import cx_Oracle

    python
    >>import cx_Oracle
    >>import cx_Oracle

    ## Refrences
    * https://gist.github.com/thom-nic/6011715
    * https://gist.github.com/kubo/8a45c653d06040c30135
    * https://sourceforge.net/p/cx-oracle/mailman/message/34534872/

  6. broqdev revised this gist Apr 8, 2016. 1 changed file with 33 additions and 47 deletions.
    80 changes: 33 additions & 47 deletions cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -1,71 +1,57 @@
    # Installing cx_Oracle for Python/ Mac OSX

    Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html (in case that link ever dies.)
    # Installing cx_Oracle (x86_64) for Mac OSX (tested on El Capitan 10.11.4)

    Assume you've got [homebrew](http://mxcl.github.com/homebrew/) installed.

    Assume python is installed through

    brew install python --universial

    ## Install instant client

    Download the following files from [Oracle](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)

    * [instantclient-basic-$VERSION-macosx-x64.zip](http://download.oracle.com/otn/mac/instantclient/11203/instantclient-basic-macos.x64-11.2.0.3.0.zip)
    * [instantclient-sdk-$VERSION-macosx-x64.zip](http://download.oracle.com/otn/mac/instantclient/11203/instantclient-basiclite-macos.x64-11.2.0.3.0.zip)
    * instantclient-basic-macos.x64-11.2.0.4.0.zip
    * instantclient-sdk-macos.x64-11.2.0.4.0.zip

    Download source code of cx_Oracle (https://sourceforge.net/projects/cx-oracle/files/5.1.2/)

    * cx_Oracle-5.1.2.tar.gz

    Create a directory `/usr/lib/share/oracle`

    export ORACLE_HOME=/usr/lib/share/oracle
    export VERSION=11.2.0.3.0
    export ARCH=x86_64

    mkdir -p $ORACLE_HOME


    Unpack both files to that directory:

    cd $ORACLE_HOME
    tar -xzf instantclient-basic-$VERSION-macosx-x64.zip
    tar -xzf instantclient-sdk-$VERSION-macosx-x64.zip
    tar -xzf instantclient-basic-macos.x64-11.2.0.4.0.zip
    tar -xzf instantclient-sdk-macos.x64-11.2.0.4.0.zip

    ln -s libclntsh.dylib.11.1 libclntsh.dylib
    ln -s libocci.dylib.11.1 libocci.dylib

    curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
    ruby fix_oralib.rb --absolute-path

    ln -s libclntsh.dylib.11.2 libclntsh.dylib
    ln -s libocci.dylib.11.2 libocci.dylib
    ## Build and install cx_Oracle

    export DYLD_LIBRARY_PATH=$ORACLE_HOME
    export LD_LIBRARY_PATH=$ORACLE_HOME


    (Note I did not have to do anything with `ottclasses.zip` as suggested in the original utexas instructions.)


    ## If you're using Pip:

    Last step is to simply run `pip`, you might have to add an arch flag:

    env ARCHFLAGS="-arch $ARCH" pip install cx_Oracle
    export OCI_LIB_DIR=$ORACLE_HOME
    export OCI_INC_DIR=$ORACLE_HOME/sdk/include

    mkdir ~/cx
    cd ~/cx
    tar -xzf cx_Oracle-5.1.2.tar.gz

    ## If you're building from source:
    python setup.py build install

    Download cx_Oracle-version.tar.gz [from Sourceforge](http://cx-oracle.sourceforge.net/)
    If there is some permission problem during "python setup.py", don't use "sudo" but try to use "chown" to get permission.


    export CX_ORA_VERSION=5.1.2
    tar -xzf cx_Oracle-$CX_ORA_VERSION.tar.gz
    cd cx_Oracle-$CX_ORA_VERSION
    ## Test
    Run python and try to import cx_Oracle

    env ARCHFLAGS="-arch $ARCH" python setup.py build
    sudo python setup.py install


    ## Notes

    Some folks have recommended compiling for 32-bit (i386) instead, although I'm not sure why. 64 bit seems to work for me so YMMV.

    Basically:

    # compile cx_Oracle for 32-bit (requires downloading 32-bit instantclient sources)
    ARCHFLAGS="-arch i386" pip install cx_Oracle

    # then make your virtualenv python 32-bit only:
    virtualenv .
    mv bin/python python.fat
    lipo python.fat -remove x86_64 -output bin/python

    See: http://stackoverflow.com/questions/8169946/cant-get-cx-oracle-to-work-with-python-version-2-7-mac-os-10-7-2-lion-mis/8452731#8452731
    python
    >>import cx_Oracle
  7. @thom-nic thom-nic created this gist Jul 16, 2013.
    71 changes: 71 additions & 0 deletions cx_oracle_instructions.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    # Installing cx_Oracle for Python/ Mac OSX

    Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html (in case that link ever dies.)

    Assume you've got [homebrew](http://mxcl.github.com/homebrew/) installed.

    Download the following files from [Oracle](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)

    * [instantclient-basic-$VERSION-macosx-x64.zip](http://download.oracle.com/otn/mac/instantclient/11203/instantclient-basic-macos.x64-11.2.0.3.0.zip)
    * [instantclient-sdk-$VERSION-macosx-x64.zip](http://download.oracle.com/otn/mac/instantclient/11203/instantclient-basiclite-macos.x64-11.2.0.3.0.zip)

    Create a directory `/usr/lib/share/oracle`

    export ORACLE_HOME=/usr/lib/share/oracle
    export VERSION=11.2.0.3.0
    export ARCH=x86_64

    mkdir -p $ORACLE_HOME


    Unpack both files to that directory:

    cd $ORACLE_HOME
    tar -xzf instantclient-basic-$VERSION-macosx-x64.zip
    tar -xzf instantclient-sdk-$VERSION-macosx-x64.zip

    ln -s libclntsh.dylib.11.2 libclntsh.dylib
    ln -s libocci.dylib.11.2 libocci.dylib

    export DYLD_LIBRARY_PATH=$ORACLE_HOME
    export LD_LIBRARY_PATH=$ORACLE_HOME


    (Note I did not have to do anything with `ottclasses.zip` as suggested in the original utexas instructions.)


    ## If you're using Pip:

    Last step is to simply run `pip`, you might have to add an arch flag:

    env ARCHFLAGS="-arch $ARCH" pip install cx_Oracle


    ## If you're building from source:

    Download cx_Oracle-version.tar.gz [from Sourceforge](http://cx-oracle.sourceforge.net/)


    export CX_ORA_VERSION=5.1.2
    tar -xzf cx_Oracle-$CX_ORA_VERSION.tar.gz
    cd cx_Oracle-$CX_ORA_VERSION

    env ARCHFLAGS="-arch $ARCH" python setup.py build
    sudo python setup.py install


    ## Notes

    Some folks have recommended compiling for 32-bit (i386) instead, although I'm not sure why. 64 bit seems to work for me so YMMV.

    Basically:

    # compile cx_Oracle for 32-bit (requires downloading 32-bit instantclient sources)
    ARCHFLAGS="-arch i386" pip install cx_Oracle

    # then make your virtualenv python 32-bit only:
    virtualenv .
    mv bin/python python.fat
    lipo python.fat -remove x86_64 -output bin/python

    See: http://stackoverflow.com/questions/8169946/cant-get-cx-oracle-to-work-with-python-version-2-7-mac-os-10-7-2-lion-mis/8452731#8452731