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?

2
  • Do you want to change default python version? Commented Nov 11, 2012 at 3:27
  • What about python2 or python27? Commented Nov 11, 2012 at 3:54

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

To override this setting for scripts, see PEP 397 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.
Work perfectly, but instead of running the command py -3. Won't it just be easier if I type in python and not py.
Probably. I just thought it worth mentioning that "py" can launch any version of python you specify.
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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.