user3524165
user3524165

Reputation:

Multiple Python versions in one computer (windows 7)

I have two versions of Python installed in my computer, Python 3.4 and Python 2.7, and I use both of these installations. When I run a script, how do I choose which versions I want to use? May I rename the names of the executables for that (Python.exe -> Python27.exe)?

Thanks.

Upvotes: 0

Views: 351

Answers (2)

Zak
Zak

Reputation: 3253

I am using a 32-bit and a 64-bit version of Python 2.7.6 on the same Windows machine, and the solution to that was to use Winpython for the 64-bit version, which is portable. The downside is that doubleclicking in the file manager will attempt to run a Python script with the 32-bit version (which is a non-portable installation), but I'm mostly writing and running scripts inside Spyder, and there's one version of it with each Python installation. Both have independent Pythonpaths, and have never had any problems with each other. Winpython is aimed at scientific use, though, so it may not come with all the libraries you may need.

Upvotes: 0

Steve Barnes
Steve Barnes

Reputation: 28370

Both python 2.7 and python 3 coexist on one machine happily.

If you name the scripts .py for those you would like to run with python 2.3 and .py3 for those that you would like to run with python3 then you can just invoke the scripts by typing their names or by double clicking. These associations are set up by default by the installer.

You can force the python version on the command line, assuming both are on the path by typing python or python3 for any script file regardless of the extension.

It is also worth looking at virtualenv for your testing.

N.B. For installing from pypi you can use pip or pip3 and the install for the appropriate version will be done.

Upvotes: 1

Related Questions