Reputation: 1530
I have python 3.2 installed and I want to know if I have to uninstall earlier versions before installing newer ones.
Upvotes: 7
Views: 40895
Reputation: 1445
It generally depends on what OS you are running and how you installed your python. Under linux or Mac OSX, you don't need to unistall the previous version. I am not sure how things are handled for Windows.
Upvotes: 0
Reputation: 177600
Install all the Python X.Y versions you want, but include Python 3.3 or later (last is best, or reinstall it after all the others) to get the Python Launcher that @abarnert mentioned in his comments. It is also available as a standalone installer.
Earlier versions than 3.3 should not register extensions, so the launcher installed by 3.3 or later will remain the default handler for .py
files.
From the command line:
py -2 # launch latest 2.x version installed.
py -3 # latest 3.x
py -3.2 # run exact version
py -3.2-32 # run 32-bit version on 64-bit system.
So you can even have mixed 32-bit and 64-bit installations.
The environment variable PY_PYTHON
can be set to specify the default Python to run.
In scripts, add a comment of the following forms below to use that version of Python when the script is double-clicked or run from command line via py script.py
:
#!python2
#!python3
#!python3.2
#!python3.2-32
See PEP 397 for further details.
Upvotes: 6
Reputation: 184151
You can install multiple versions of Python on Windows, but only the last version you installed will be used by default: when double-clicking a .py
file in Windows Explorer, when typing just python
at the command line, etc. "Edit in IDLE" on the context menu also uses the last version you installed. To use other versions you'll need to specify the full path of the version you want. Also, if you use the PYTHONPATH
environment variable, there's only one of those, and the scripts in the directories specified in PYTHONPATH
may or may not work with whatever version of Python you happen to be running. This can be worked around by writing a batch file that sets PYTHONPATH
before launching Python.
Upvotes: 1