Wednesday, June 12, 2013

Django, Windows7, Virtualenv, TCC/LE

Today I have been Wrestling to set up a development environment for Django 1.5.1 on Windows7 using Virtual environment.  As normal in real life there were a number of complications such as:

  • I have a number programs on my laptop which install and run different versions of Python (such as ArGIS and SPSS)
  • I had previously installed an older version of Django in one of the python installs.
These complications were compounded by the fact Virtualenv keeps loading global site packages on Windows as described here.  After a morning of searching google and stackoverflow and trying out different suggestions I found this very easy to follow guide by Jtiai which solved all my problems.

The key section that solved my conflicting python issues under virtualenv was the following configuration of TCC/LE command shell. (I wonder if you can configure cmd.exe in a similar way?).

Under working directory create subdirectory config. In this directory create startup file for TCC/LE called tcstart.btm
@echo off
rem Override system python binding to handle virtualenvironments
set .py;.pyc=python.exe
Now create (copy) TCC/LE shortcut on desktop and rename it appropriately. Open Properties for shortcut and add to Target “C:\django\config\tcstart.btm”. You probably want to set Start in to something useful, like C:\django
For the record the environment I have now installed comprises of:
  • Python 2.7
  • Django 1.5.1
  • virtualenv 1.9.1
  • TCC LE 13.0