17.09.2019»»вторник

Installing Cx_Oracle On Windows 7

17.09.2019
    81 - Comments

It is what it is. Home About Links Home > Coding, Inspired, Intuition > Installing cx_Oracle on Windows. Installing cx_Oracle on Windows. July 28th, 2010 Leave a comment Go to comments.

  1. Install Oracle On Windows
I just had a surprisingly hard time getting cx_Oracle 5.0.2 installed on a new Vista machine (with Oracle Client 11.1.0.7, Python 2.6) using the windows .msi installer. Eventually, I managed to get it installed only when all the following were true:
- Running as Administrator
- ORACLE_HOME set in Environment Variables (Computer => Properties => Advanced System Settings). Simply issuing 'set ORACLE_HOME=c:appproduct11.1.0client_1' from the command prompt does not seem to do it.
- Any previous failed installations must be removed, not simply repaired.
If any of these are not true, the installation still appears to work - the installer runs and completes without complaint. Trying to actually 'import cx_Oracle', however, gives
ImportError: No module named cx_Oracle
I'm posting this here because, without an error message from the installer or any mention in the documentation or the README, this seems like the sort of sneaky problem that could make newbie Python users quit in frustration. (Also, I'll be able to find it here myself..)
Edited by: catherinedevlin on Jun 26, 2009 11:50 AM
Edited by: catherinedevlin on Jun 26, 2009 1:50 PM

Hey,

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

Just installing cx_Oracle on a fresh Solaris 11 box.

root@zion11:~# python

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

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

>>>

root@zion11:~# echo $ORACLE_HOME

/opt/oracle/instantclient_11_2

root@zion11:~# 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

root@zion11:~# 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

Install Oracle On Windows

/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 Facebook app download for nokia 6600.

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('rn', '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

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

Windows

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('rn', '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.

root@zion11:~# which gcc

/usr/bin/gcc

root@zion11:~# 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:

Oracle

root@zion11:~# 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.

root@zion11:~# cd /usr/src/cx_Oracle-5.1.2/

root@zion11:/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

root@zion11:/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?

 fullpacviva © 2019