Is there a way to install python 3 over an installation of python 2 without ruining anything? The main issue is that I have code that runs by “python abc123”. Is there a way to change python 3 to be “python3 abc123”? The same command python is the conflict

There is a better way of coexistence/launching of Python 2 and Python 3 on Windows. The Python 3.3 introduced the Python launcher for Windows (see

After installation of Python 3.3, the py.exe and pyw.exe is copied to your c:\Windows directory, and the associations are set for the .py extension so that it uses the launcher. By default, Python 2 is launched for py The py -3 launches Python 3. (This also means that no path for Python must be added to the environment — the C:\Windows already is in the PATH.)

The best of all is that #!python2 in the script causes lauching via Python 2, the #!python3 causes launching the script via Python 3. This way, you can use scripts for both versions of Python, and you can lauch them the unified way — py or by just clicking on the script icon.

There are more details but this is basically what you need.

Update: When using Python launcher for Windows, you can also launch your Python script from cmd window by typing > (that is without explicitly typing py–the name of the Python launcher–in front of the script name) or even by typing the name without the .py extension (that is just > script).

This way, things start to resemble the Unix way of naming scripts (without the need for the extension); however, you still have to add the .py extension when creating the script file.

(Yes, it is a bit more messy than the Unix approach. This is the difference between the “Think first!” and the “Sell first!” approaches of developments of the OSes. Anyway, my kudos to the Python development team to squeeze the best out of the Windows — by releasing the Python launcher for Windows.)

Not sure if it would meet your needs, but you should take a look at virtualenv:

This will let you create separate environments for Python 2 and 3 (using the -p flag). If your use case is something for which this wouldn’t work, update the question with some more specifics and I’m sure you’ll get other suggestions.

Assuming that you install python3 in a separate directory, you could also rename the python 3 executable to be python3.exe.

You need to edit your environment variable to include your Python 3 or Python 2 path.