6

I would like to install both python 2.7 and python 3.5 on my Windows 10 PC. Both python executables use the same name python.exe.

Is it a good idea to change python.exe to python3.exe as a quick fix for co-existence? Are there any side-effects or other things that I need to be aware?

2
  • Why are you installing both? wiki.python.org/moin/Python2orPython3 Commented Oct 5, 2016 at 1:52
  • I have a variant on this problem - I have both 32 bit and 64 bit versions of python (needed by different programs, for example my 64 bit Z3 can only run under 64 bit python). I would like to have both pythons on my path with different names for the exe's obviously. Any ideas? Commented Jan 7, 2019 at 3:08

2 Answers 2

14

You don't need to rename anything for co-existence of different versions of Python.

The different versions of python are installed on different folders automatically.

When use the command prompt you can use the commands py2 or py3 to refer to the different versions of python. The next works too:

C:\Users\user1>py -2

and

C:\Users\user1>py -3

This also works with pip2 and pip3 for install new packages.

For more details, you can read this article: Python Launcher for Windows.

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

8 Comments

user16891328: If you have both installed, you can also add a #!/usr/bin/env python2 or #!/usr/bin/env python3 comment as the first line of your scripts and use py scriptname.py to have the correct interpreter executed.
@martineau This is a Windows question
@cricket_007: I know that. py makes the shebang work on Windows, too.
@martineau I meant #!/usr/bin/env
@cricket_007: I understood what you meant. See this section of the documentation where it says the the py launcher makes the same thing work on Windows.
|
1

You'll need to run python3 instead of python if that's not obvious. This is definitely, as you described, a "quick fix"

My suggested fix is to use virtualenv and pass in the Python executable you would like to use as so:

virtualenv -p /usr/bin/python3.5 /my/virtualenv/>

1 Comment

You can change that to wherever your Python 3.5 exe is found.

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.