5

I'm using windows xp.

I'm trying to use Python in powershell. On my computer I have both Python 3.3 and 2.7 installed. I'm trying to run 2.7 but whenever I type "python" into powershell it opens 3.3.

How do I select the version of Python to run?

davids
  • 5,397
  • 12
  • 57
  • 94
The Guy
  • 53
  • 1
  • 1
  • 3

2 Answers2

10

In powershell, enter the following:

$Env:PY_PYTHON = 2

Then try using the command "py". It should start up Python 2.7. If you ever want to run Python 3.3 again, "py -3" will do the trick.

ChimeraObscura
  • 1,944
  • 14
  • 9
  • To override this setting for scripts, see [PEP 397](http://www.python.org/dev/peps/pep-0397/) regarding shebangs in Windows. With the 3.3 installer, `py.exe` and `pyw.exe` are associated with .py and .pyw files, and they process the shebang line. – Eryk Sun Nov 11 '12 at 07:18
  • Work perfectly, but instead of running the command py -3. Won't it just be easier if I type in python and not py. – The Guy Nov 11 '12 at 23:14
  • Probably. I just thought it worth mentioning that "py" can launch any version of python you specify. – ChimeraObscura Nov 12 '12 at 03:08
1

Something like Python Select? Windows support is experimental but it might be worth a try.

https://github.com/Activestate/pythonselect

There's also switchpy, although that only supports up to Python 3.2.

apipes.blogspot.com/2010/10/switchpy.html?m=1

Talvalin
  • 7,789
  • 2
  • 30
  • 40