views:

80

answers:

2

I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.

Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.

Thanks.

+1  A: 

You can install multiple versions of Python one machine, and during setup, you can choose to have one of them associate itself with Python file extensions. If you install modules, there will be different setup packages for different versions, or you can choose which version you want to target. Since they generally install themselves into the site-packages directory of the interpreter version, there shouldn't be any conflicts (but I haven't tested this). To choose which version of python, you would have to manually specify the path to the interpreter if it is not the default one. As far as I know, they would share the same PATH and PYTHONPATH variables, which may be a problem.

Note: I run Windows XP. I have no idea if any of this changes for other versions, but I don't see any reason that it would.

l33tnerd
I have python 2.5, 2.6 and 3.1 all installed simultaneously, It never even occured to me that i might have to do something harder than just run all of the installers for each version I need.
TokenMacGuy
A: 

I have multiple versions in windows. I just change the exe name of the version I'm not defaulting to.

python.exe --> python26.exe

pythonw.exe --> pythonw26.exe

As for package installers, most exe installers allow you to choose the python install to add the package too. For manual installation check out the --prefix option to define where the package should be installed:

http://docs.python.org/install/index.html#alternate-installation-windows-the-prefix-scheme

monkut
This worked. Before making this change, when I tried to run a program in Python 2.7, it still ran in Python 3.1 (Perhaps because Windows 7 can't handle two different programs with the same name). After renaming the exe's as shown, everything went well.
dln385