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:
- Visit the Oracle website (http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html), accept the license agreement, and download "Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)" (or, x86 if you're running 32-bit Windows).
- As of 2012.04.10, the MD5 of the 64-bit version was 0E73BC845884D6D0D927C22134F24C9F (win64_11gR2_client.zip) and worked on Windows 7.
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\paver-script.py", line 9, in <module> load_entry_point('Paver==1.0.5', 'console_scripts', 'paver')() File "c:\Python-Dev\heron\lib\site-packages\paver\tasks.py", line 689, in main _launch_pavement(args) File "c:\Python-Dev\heron\lib\site-packages\paver\tasks.py", line 669, in _lau nch_pavement execfile(environment.pavement_file, mod.__dict__) File "pavement.py", line 21, in <module> import heron_build File "heron_build.py", line 104, in <module> import db_util File "db_util.py", line 34, in <module> import cx_Oracle ImportError: No module named cx_Oracle