[Tutor] Running multiple version of Python on 1 windows machine

Kent Johnson kent37 at tds.net
Tue Oct 31 03:00:43 CET 2006


Todd Dahl wrote:
> At work I have installed Python 2.4 but at home I have Python 2.5.
> Until this point I didn't think nothing of it but now I have run into
> a issue.
> 
> I have some code that I have worked on at work that uses the pySQLite
> module which doesn't support 2.5, yet. I can run my code at work but I
> can't even install the module at home.
> 
> So my question is how do I configure my machine at home so I can have
> multiple versions of python running so I can run this code. Or is this
> a bad and/or confusing thing to do.

pysqlite is included in the standard library in Python 2.5, that is why 
there is no support on the pysqlite web site.

The package name is different, you can write the code with conditional 
imports e.g.

try
   import sqlite3 as sqlite # Python 2.5
except ImportError:
   from pysqlite2 import dbapi2 as sqlite

If changing the code is not an option you might be able to fake it out 
by making a pysqlite2.dbapi2 module that just contains
   from sqlite3 import *

I haven't tried any of this so I could be off base. I'm assuming that 
the bundled version is the same as the one you have at work other than 
the package name

You don't say what OS you are running but under Windows it is trivial to 
have multiple versions of Python installed, I have 2.3, 2.4 and 2.5. 
They are each in their own directories, all in the system path. I have 
aliases called py23, py24 and py25 that let me launch the version I 
want. I'm pretty sure you can do something similar with other OSes.

Kent



More information about the Tutor mailing list