Forum Stats

  • 3,769,895 Users
  • 2,253,029 Discussions
  • 7,875,233 Comments

Discussions

Install Python cx_Oracle on Solaris 11

Jan Schreiber
Jan Schreiber Member Posts: 13 Blue Ribbon
edited Aug 4, 2014 7:29PM in Python

Hey,

I really didn't expect this to be that hard:

Just installing cx_Oracle on a fresh Solaris 11 box.

[email protected]:~# python

Python 2.6.8 (unknown, Feb 26 2014, 19:21:08) [C] on sunos5

Type "help", "copyright", "credits" or "license" for more information.

>>>

[email protected]:~# echo $ORACLE_HOME

/opt/oracle/instantclient_11_2

[email protected]:~# echo $LD_LIBRARY_PATH

/opt/oracle/instantclient_11_2

Okay, fine. Let's go to work:

# which pip

no pip in /usr/bin /usr/sbin /opt/csw/bin /bin /sbin

# which easy_install

no easy_install in /usr/bin /usr/sbin /opt/csw/bin /bin /bin

Great. I am on Oracle hardware, using an Oracle OS and pre-installed python, and just want to connect to my Oracle database. Why isn't cx_Oracle pre-installed in the first place? Or am I just missing some pkg package I could use?

But wait, luckily, there is OpenCSW.

# pkgutil -i python26 py_setuptools py_pip

[email protected]:~# pip install cx_Oracle

Downloading/unpacking cx-Oracle

  Downloading cx_Oracle-5.1.3.tar.gz (104kB): 104kB downloaded

  Running setup.py egg_info for package cx-Oracle

  

Installing collected packages: cx-Oracle

  Running setup.py install for cx-Oracle

    building 'cx_Oracle' extension

    /opt/csw/bin/gcc-4.8 -O2 -pipe -m32 -march=pentiumpro -fno-strict-aliasing -O2 -pipe -m32 -march=pentiumpro -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/opt/csw/include/python2.7 -c cx_Oracle.c -o build/temp.solaris-2.11-i86pc.32bit-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3

    unable to execute /opt/csw/bin/gcc-4.8: No such file or directory

    error: command '/opt/csw/bin/gcc-4.8' failed with exit status 1

    Complete output from command /opt/csw/bin/python2.7 -c "import setuptools;__file__='/tmp/pip_build_root/cx-Oracle/setup.py';exec(compile(open(__file__).read().replace('', '\n'), __file__, 'exec'))" install --record /tmp/pip-Cqt1z4-record/install-record.txt --single-version-externally-managed:

    running install

running build

running build_ext

building 'cx_Oracle' extension

creating build

creating build/temp.solaris-2.11-i86pc.32bit-2.7-11g

/opt/csw/bin/gcc-4.8 -O2 -pipe -m32 -march=pentiumpro -fno-strict-aliasing -O2 -pipe -m32 -march=pentiumpro -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/opt/csw/include/python2.7 -c cx_Oracle.c -o build/temp.solaris-2.11-i86pc.32bit-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3

unable to execute /opt/csw/bin/gcc-4.8: No such file or directory

error: command '/opt/csw/bin/gcc-4.8' failed with exit status 1

----------------------------------------

Cleaning up...

Command /opt/csw/bin/python2.7 -c "import setuptools;__file__='/tmp/pip_build_root/cx-Oracle/setup.py';exec(compile(open(__file__).read().replace('', '\n'), __file__, 'exec'))" install --record /tmp/pip-Cqt1z4-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/cx-Oracle

Storing complete log in /root/.pip/pip.log

Well, okay, this is not at all the installed GCC version.

[email protected]:~# which gcc

/usr/bin/gcc

[email protected]:~# gcc -v

Lesen der Spezifikationen von /opt/csw/lib/gcc/i386-pc-solaris2.10/4.9.0/specs

COLLECT_GCC=/opt/csw/bin/gcc

COLLECT_LTO_WRAPPER=/opt/csw/libexec/gcc/i386-pc-solaris2.10/4.9.0/lto-wrapper

Ziel: i386-pc-solaris2.10

Konfiguriert mit: /home/maciej/src/opencsw/pkg/gcc4/trunk/work/solaris10-i386/build-isa-pentium_pro/gcc-4.9.0/configure --prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin --sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share --sysconfdir=/etc/opt/csw --sharedstatedir=/opt/csw/share --localstatedir=/var/opt/csw --libdir=/opt/csw/lib --infodir=/opt/csw/share/info --includedir=/opt/csw/include --mandir=/opt/csw/share/man --enable-cloog-backend=isl --enable-java-awt=xlib --enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada --enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix --program-suffix=-4.9 --with-cloog=/opt/csw --with-gmp=/opt/csw --with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld --with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw --with-system-zlib=/opt/csw --with-gnu-as --with-as=/opt/csw/bin/gas

Thread-Modell: posix

gcc-Version 4.9.0 (GCC)

Can I configure this anywhere?

Or, maybe something else:

[email protected]:~# easy_install cx_Oracle

Searching for cx-Oracle

Reading https://pypi.python.org/simple/cx_Oracle/

Reading http://cx-oracle.sourceforge.net

Reading http://starship.python.net/crew/atuining

Best match: cx-Oracle 5.1.3

Downloading https://pypi.python.org/packages/source/c/cx_Oracle/cx_Oracle-5.1.3.tar.gz#md5=cd6ff16559cbc9c20087ec812c7092ab

Processing cx_Oracle-5.1.3.tar.gz

Writing /tmp/easy_install-9a7QmG/cx_Oracle-5.1.3/setup.cfg

Running cx_Oracle-5.1.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9a7QmG/cx_Oracle-5.1.3/egg-dist-tmp-agKYF3

unable to execute /opt/csw/bin/gcc-4.8: No such file or directory

error: Setup script exited with error: command '/opt/csw/bin/gcc-4.8' failed with exit status 1

Okay, so let's try it DIY.

[email protected]:~# cd /usr/src/cx_Oracle-5.1.2/

[email protected]:/usr/src/cx_Oracle-5.1.2# python setup.py build

running build

running build_ext

building 'cx_Oracle' extension

/usr/lib/python2.6/pycc -DNDEBUG -KPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.solaris-2.11-i86pc-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.2

gcc: unrecognized option '-KPIC'

/usr/lib/python2.6/pycc -G build/temp.solaris-2.11-i86pc-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2 -L/usr/lib -lclntsh -lpython2.6 -o build/lib.solaris-2.11-i86pc-2.6-11g/cx_Oracle.so

ld: fatal: library -lclntsh: not found

ld: fatal: file processing errors. No output written to build/lib.solaris-2.11-i86pc-2.6-11g/cx_Oracle.so

collect2: ld returned 1 exit status

error: command '/usr/lib/python2.6/pycc' failed with exit status 1

[email protected]:/usr/src/cx_Oracle-5.1.2# ls -lhrt /opt/oracle/instantclient_11_2/libclntsh.so.11.1

-rwxr-xr-x   1 root     root         50M Aug  2 17:40 /opt/oracle/instantclient_11_2/libclntsh.so.11.1

Any ideas?

Best Answer

  • jmcp-Oracle
    jmcp-Oracle Member Posts: 8
    Accepted Answer

    I've built and installed cx_Oracle 5.1.1 for use on Solaris, but haven't put them into an IPS package - too many projects going on. Doing so is very much on my todo list (as is offering those changes upstream).

    In the meantime, here's what you need to know.

    Firstly - the pycc wrapper that we ship in Solaris is written assuming use of Solaris Studio compiler options. That's why you saw  "gcc: unrecognized option '-KPIC'" in the output above. To get past this, install the Solaris Studio compiler - it's available on pkg.oracle.com from the solarisstudio repository; please see Oracle Solaris Studio Downloads for details.

    Secondly - I had to create symlinks by hand in the extracted Oracle Instant Client directory after installing from the tarball. I'm not sure if you need to do that when installing pkg://solarisstudio/developer/solarisstudio-123/library/oic-libs and pkg://solarisstudio/developer/solarisstudio-123/oic. One thing the tarball option gives you is the opportunity to install the 64bit client libraries as well.

    Once I had the instant client bits installed, I ran the setup.py script like this:

    $ ORACLE_HOME=/opt/oracle/instant_client_11_2 LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2: python setup.py

Answers

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,643 Employee

    I've prodded some Solaris folk to look at your post.

    cx_Oracle is 3rd party open source software so it's not totally

    surprising that it isn't pre-installed on Solaris.

    Regarding the DIY method at the end of your post, did you create the

    symbolic links mentioned in the Instant Client installation

    documentation? http://docs.oracle.com/database/121/LNOCI/oci01int.htm#LNOCI16174

  • jmcp-Oracle
    jmcp-Oracle Member Posts: 8
    Accepted Answer

    I've built and installed cx_Oracle 5.1.1 for use on Solaris, but haven't put them into an IPS package - too many projects going on. Doing so is very much on my todo list (as is offering those changes upstream).

    In the meantime, here's what you need to know.

    Firstly - the pycc wrapper that we ship in Solaris is written assuming use of Solaris Studio compiler options. That's why you saw  "gcc: unrecognized option '-KPIC'" in the output above. To get past this, install the Solaris Studio compiler - it's available on pkg.oracle.com from the solarisstudio repository; please see Oracle Solaris Studio Downloads for details.

    Secondly - I had to create symlinks by hand in the extracted Oracle Instant Client directory after installing from the tarball. I'm not sure if you need to do that when installing pkg://solarisstudio/developer/solarisstudio-123/library/oic-libs and pkg://solarisstudio/developer/solarisstudio-123/oic. One thing the tarball option gives you is the opportunity to install the 64bit client libraries as well.

    Once I had the instant client bits installed, I ran the setup.py script like this:

    $ ORACLE_HOME=/opt/oracle/instant_client_11_2 LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2: python setup.py

This discussion has been closed.