in progress (#1046): re-focus this page on installing cx_Oracle and other non-pure-python dependencies on Windows. Migrate the general dev tools discussion to: WritingQualityCode

Our HeronLoad ETL process uses python to knit together SQL scripts using paver and cx_Oracle.

Installing the Oracle client

todo: refactor this and the next section

In order for the cx_Oracle library to work properly, you'll likely need to install the oracle client. To do so:

Installing cx_Oracle

We use cx_Oracle to connect to Oracle from python:

cx_Oracle is a Python extension module that allows access to Oracle databases and conforms to the Python database API specification.

Visit the cx_Oracle site and download the appropriate installer. In my case:

  • Windows x86 Installer (Oracle 10g, Python 2.7) I chose this because I have installed Python 2.7
  • NOTE: You must match the Python/cx_Oracle/Oracle Client install "bitness" (they must all be 32-bit or all be 64-bit). Otherwise, you'll get an error when trying to import cx_Oracle (or running paver) that says something about "invalid executable".

Once we extract(run) the msi we chose default options (including the registry version of Python 2.7) to install the libraries.

Next, copy the following files from the python site packages folder (i.e. c:\python27\lib\site-packages) to your virtual environment site packages directory (i.e. C:\Python-Dev\heron\Lib\site-packages).

  • cx_Oracle.pyd
  • cx_Oracle-5.1.1-py2.7.egg-info

To check that oracle is installed correctly:

(heron) C:\Documents and Settings\achoudhary\Desktop\bmidev\heron_load>python
Python 2.7.1 (!r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle

The 2nd >>> sign above indicates that virtual environment setup worked.

Installing Paver

The HeronLoad code depends on the paverlibrary. To add it to our virtualenv environment, run the following command on the dos prompt:

> pip install paver

If you get the following errors when running paver, check to make sure the cx_Oracle files were copied correctly and then restart the virtual environment.

(heron) C:\Users\ngraham\code\heron_load>paver help
Traceback (most recent call last):
  File "c:\Python-Dev\heron\Scripts\", line 9, in <module>
    load_entry_point('Paver==1.0.5', 'console_scripts', 'paver')()
  File "c:\Python-Dev\heron\lib\site-packages\paver\", line 689, in main
  File "c:\Python-Dev\heron\lib\site-packages\paver\", line 669, in _lau
    execfile(environment.pavement_file, mod.__dict__)
  File "", line 21, in <module>
    import heron_build
  File "", line 104, in <module>
    import db_util
  File "", line 34, in <module>
    import cx_Oracle
ImportError: No module named cx_Oracle
Last modified 9 years ago Last modified on May 5, 2012 10:49:35 AM