Thursday, 16 May 2013

Local Python development environment


What
This is a short "howto" on setting up a local development environment, using Python 2.7 with cx_Oracle (against Oracle 11g) and Mongoose web server, on a 64 bit Windows 7 system.

Prerequisite
Having set up Oracle Instant Client.

Python
Install Python from ActiveState.
Version: 2.7.2.5 Win 64-bit / x64.

cx_Oracle
Install cx_Oracle module for Python.
Version: Windows amd64 Installer (Oracle 11g, Python 2.7).

Mongoose
Download and run the Mongoose web server (no installation needed).
Version: mongoose-3.7.exe.

Alter settings, add .py to "cgi_pattern" and add pythonw.exe as cgi_intepreter. Set "document_root" to the root of your web project. You might want to add log files as well (to change settings right click the little Mongoose icon in the system tray menu).
Mongoose settings.

Do you see the Mongoose? Right click it...

You might run into error message:
CGI program sent malformed or too big (>16384 bytes) HTTP headers

In my case this was due to missing cx_Oracle module. Try running your .py script from the command line, and fix any missing library errors:

C:\Users\klevstul\\projects\sleepTracker\trunk\cgi>C:\prgFiles\Python27\python.exe jsonRpc.py
Traceback (most recent call last):
  File "jsonRpc.py", line 17, in <module>
    import cx_Oracle
ImportError: No module named cx_Oracle

Start developing
Your web server is located on localhost, so just get started with the development.

All set!


No comments:

Post a Comment

Allowed HTML tags:
<b>bold</b>
<strong>strong</strong>
<i>italics</i>
<em>emphasis</em>
<a href="">hyperlink</a>


Please, show the courtesy of identifying yourself when adding a comment. Anonymous comments will, most likely, be removed.