[Tutor] running multiple versions of python

eryksun eryksun at gmail.com
Thu Jan 10 18:44:27 CET 2013


On Thu, Jan 10, 2013 at 11:34 AM, Fowler, Trent <FowlerTM at hendrix.edu> wrote:
>
> Python 3.3 was the first version I installed and I was able to run scripts
> from the desktop (not the command line). I installed python 2.7 so that
> I could get numpy, scipy, and matplotlib down the road, but I found that
> all the scripts on my desktop defaulted to python 2.7.

numpy, scipy, and matplotlib are available for Python 3.

3.3 includes launchers (py.exe and pyw.exe) that process UNIX-style
shebangs in order to run a script with a given version of Python,
provided it's available. These launchers should be installed in the
Windows directory (e.g. C:\Windows). Try reinstalling 3.3. Then open a
console and verify the following settings:

    C:\>assoc .py
    .py=Python.File

    C:\>ftype Python.File
    Python.File=C:\Windows\py.ex "%1" %*

    C:\>assoc .pyw
    .pyw=Python.NoConFile

    C:\>ftype Python.NoConFile
    Python.NoConFile="C:\Windows\pyw.exe" "%1" %*


> Ideally I'd like to specify which python I want to run a script from the desktop,
> or possibly while I'm editing the script.

Refer to PEP 397 and the docs for the launcher:

https://bitbucket.org/vinay.sajip/pylauncher/src/tip/Doc/launcher.rst

For example, it accepts common UNIX shebangs such as

    #! /usr/bin/env python2

I think the launcher defaults to the latest 2.x if it's installed. If
you want a different default such as 3.3, edit py.ini in your
profile's AppData\Local folder. The following should open the file (or
create it) with notepad:

    notepad %LOCALAPPDATA%\py.ini

Refer to the "Customization via INI files" section of the docs.


More information about the Tutor mailing list