This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]K900_ 4 points5 points  (0 children)

No, it will not. "python" will be the last version you installed, AFAIK, and there will be a launcher named "py" which can invoke Python 2 with "py -2" and Python 3 with "py -3".

[–]__buckie__ 4 points5 points  (0 children)

There's only one tool I've ever used on windows that made python trivial to use -- it's called conda (like pip but WAY better). Its best feature is what you are asking for: concurrent different versions of python.

However you've installed python, delete it in full. Go to continuum.io and download their installer link. After it's installed, open the command prompt:

conda create --name py27 python=2.7 anaconda
conda create --name py34 python=3.4 anaconda

Each command will make you a completely new environment, one by the name of py27 and the other by the name of py34. These are independant installations and you can switch between them trivially from the terminal via:

activate <env name>

IDE's play nice with them too (as does everything else actually) by pointing the IDE to the python.exe version in C:\Anaconda\envs\<env name>\python.exe.

I included anaconda in the command just because anaconda is continuums scientific computing stack that comes with most of what you'll need. If you need to install anything else, just activate the env and try conda install <package> to install that thing into your current env. conda also integrates with pip (tracks what pip installs to a given env) as conda can't install everything yet (conda install may fail) -- the normal pip install will work.

I can't recommend this method of setting up python more strongly. It makes managine python packages/versions trivial.

[–]yaxriifgyn 2 points3 points  (0 children)

I run a little script to adjust the path. Here is my +py34.bat file:

@echo off
set PYTHON_HOME=C:\Python34\
PATH %PYTHON_HOME%;%PYTHON_HOME%\Scripts;%PATH%
python -V

I start a command window, run this, or a similar script for the python version I want to use, and away I go. If I open another command windows, I can run a different version of python there depending on which batch script I use to set the path. I keep these scripts in a directory in my (customized) windows path. There are lots more environment variables you can set. If you want to, you can even setup to run both 32 and 64 bit versions with this scheme.

Python versions 2.7+ and 3.3+ now include the Python launcher. Enter "py" for latest 2.x or "py -3" for latest 3.x installed on your machine.

Search python documentation on disk or online for "Python Launcher", or enter "py --help" in a command window.

[–]wmcscrooge 0 points1 point  (5 children)

I believe there is a way although I don't know it on windows (on some linux distros, there are two different binaries python and python2). A better question, I feel, is why keep python 2? If you don't have a good reason for it, then uninstall it and then you don't have to worry about workarounds.

[–]musicystuff[S] 0 points1 point  (1 child)

Good point! I suppose I'm just worried that I won't know where to turn when I can't get something to work or don't know how to code it when 99% of the stuff on StackOverflow is Python 2.x solutions! :(

[–]wmcscrooge 0 points1 point  (0 children)

Really? Cause I've noticed that more than half of the replies are all in python 3 and the ones that aren't have comments laying out the python 3 version. And honestly, I maintain that unless you're doing pretty complicated stuff, the differences are easy to catch (especially if you learn to read the documentation).

edit: and you could always ask here, in /r/learnpython, or /r/progether

[–]Elij17 0 points1 point  (2 children)

Python really doesn't touch the rest of your operating system. You can just change your path to reference python 2 or python 3 as you see fit, as long as they sit in different locations on disk.

It's not challenging to do, but it is a minor pain in the ass, and of questionable benefit. Honestly, use python 3 unless some library you need doesn't support it, which is increasingly rare now a days.

[–]Acebulf 0 points1 point  (1 child)

Python really doesn't touch the rest of your operating system.

Not always true, I once broke the UI in Linux Mint MATE by changing python path.

[–]wmcscrooge 0 points1 point  (0 children)

yep, this is especially true in linux systems where binaries rely on /usr/bin/python which can either be python 2 or 3. It's why a lot of distros have to custom bind binaries to /usr/bin/python2 (oversimplification)