6

What would be the best way/order to install both 32 and 64 bit versions of Python 2.7 and Python 3.3 if I want 64 bit Python 3.3 to be the default when I open .py files?

I already have the 32 bit version of each installed, with defaults set to Python 3.3.


If it is fine to just rename the directory of my currently installed version, will python27.dll and programmes using it (or python33.dll) continue to work? This library gets installed to %WINDIR%\System32 and/or %WINDIR%\SysWoW64 by the python installer.


Thanks for your answers, here is what I did:

  1. Uninstalled Python 3.3 (This left 2 files)
    • C:\Python33\Lib\lib2to3\Grammar3.3.0.final.0.pickle
    • C:\Python33\Lib\lib2to3\PatternGrammar3.3.0.final.0.pickle
  2. Uninstalled Python 2.7
  3. Installed Python 2.7 x86 (without register extensions)
    • C:\Python\27_32\
  4. Installed Python 2.7 x86-64 (without register extensions)
    • C:\Python\27\
  5. Installed Python 3.3 x86 (without register extensions)
    • C:\Python\33_32\
  6. Installed Python 3.3 x86-64 (with default register extensions)
    • C:\Python\33\
  7. Deleted C:\Python33
    • CCleaner'd installer reference issues to this location

3 Answers 3

3

The installer typically has an option for "Set file associations" that handles that, and I think it's on by default, which means that the most-recently-installed one will handle double-clicking .py files. So install 64-bit Python 3.3 last and it should work. I just did this a few days ago with 32- and 64-bit version of 2.7 and it seems to work fine.

I wouldn't rename your existing directory, though. You should install each version of Python in its own directory.

2

Use the PEP 397 launcher and configure it to launch your preferred version of Python. A copy comes with all versions of Python 3.3, or you can install it separately.

To elaborate:

Rather than launching Python by typing python in a shell, run py.exe (this should also be the default action for double clicking on a Python file if the most recently installed version is Python 3.3 or later). py.exe is a helper program that searches for and locates an appropriate version of Python on your system.

You can edit an .ini file in various locations to specify the default version, or your Python scripts can specify the version they expect to be run with (using a "shebang" line, as described in the PEP). So you can set your system default to be 64-bit Python 3.3, while also allowing individual scripts to use other versions on demand.

3
  • This looks interesting but I couldn't find any info on how it could tell the difference between bit-versions unless I edited the .ini, but then it would mean the shebang lines wouldn't work for anyone else.
    – Paul S.
    Nov 15, 2012 at 16:04
  • 1
    I'm not sure what you mean. A shebang line of #!python (or for Unix compatibility, #!/usr/bin/python) will always launch the highest version of Python 2 available, with a 64 bit version preferred if both 32 and 64-bit are available for that version. You can use #!python3 to request Python 3, or #!python3.2 to explicitly require Python 3.2, even if 3.3 is available. You an use #!python2.6-32 if your script will only run on Python 2.6 32-bit. You only need to modify the .ini file if you want to modify the defaults (to prefer Python 3 over 2, or 3.2 over 3.3, for instance).
    – Blckknght
    Nov 15, 2012 at 23:32
  • Ah, I only saw the command line switch section for choosing 32 bit. Thanks! This will most likely be useful for me.
    – Paul S.
    Nov 15, 2012 at 23:52
-1

I would use a virtualenv for each version (2.7/3.2) or flavor (32-bit/64-bit) of python you want to install. Essentially, a virtualenv is a sandbox for your installation, which doesn't leak through into other sandboxes.

This other SO question explains how to make virtualenvs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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