Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to install 2 versions of Python on Windows 7 and if so do I just need to run the separate installers? (and all will work well if I do, without any configuration?)

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Yes. I suggest installing the version you will use the most last, because the installer adds Python to your system path adds registry entries for *.py files. These registry entries set the default "Open" action and add an "Edit with IDLE" context menu.

To use a specific version of Python, simply use the full path to the executable. And/or set the appropriate environment variables (%PATH% and %PYTHONPATH%) properly. This can be done at a Windows-wide level, then later over-ridden by a specific CMD console.


Update:

I just installed three versions of Python (2.5, 2.7, then 2.6) on Windows 7. I wanted to be able to specify which version of Python to use for "Open with IDLE", so I added some registry keys under: HKEY_CLASSES_ROOT\Python.File\shell\ in order to get two context menu items (Edit with IDLE 2.6 and Edit with IDLE 2.7):

  1. I cloned the existing Edit with IDLE key to create a new Edit with IDLE 2.7 key.
  2. Then I modified the string under the command key to use Python 2.7:
    "C:\Python27\pythonw.exe" "C:\Python27\Lib\idlelib\idle.pyw" -n -e "%1"
  3. Finally, I renamed the existing Edit with IDLE to Edit with IDLE 2.6
  4. I could have added another context menu item for Python 2.5, but I only plan to use 2.5 infrequently for Google Apps Engine.
share|improve this answer

Yes, no problem. I have it on my Windows 7 64 bit machine - I think i have Python 2.5 and 2.7 - each one was installed with other software - I think that one with Scidavis and second with Quantum GIS. Both programs are working OK. ;-)

share|improve this answer

I found that the formal way to do this is as follows:

Just install two (or more, using their installers) versions of Python on Windows 7 (for me work with 3.3 and 2.7).

Follow the instuctions below, changing the parameters for your needs.

Create the following environment variable (to default on double click):

Name:  PY_PYTHON
Value: 3

To launch a script in a particular interpreter, add the following shebang (beginning of script):

#! python2

To execute a script using a specific interpreter, use the following prompt command:

> py -2 MyScript.py

To launch a specific interpreter:

> py -2

To launch the default interpreter (defined by the PY_PYTHON variable):

> py

Resources

Documentation: Using Python on Windows

PEP 397 - Python launcher for Windows

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.