Question

I have python 2.7.6 and python 3.4 installed on windows 7 machine.

When I open command prompt for windows and type python, python 2.7.6 starts by default.

I have a python script which I want to compile (or interpret officially speaking) using python 3.4.

Is there a command to use python 3.4 from c:/ prompt? or make 3.4 the default python interpreter?

thanks

Was it helpful?

Solution

Recent versions of Python for Windows install a script called py that will do what you want.

You can either do py -3 script.py to explicitly tell the launcher that you want to use Python 3

or put something containing "python3" on the first line in a comment (ideally #!/usr/bin/env python3 for compatibility with other systems...) and just run script.py; the installer associates *.py files with the launcher, which in turn determines the version to run by looking at the first line of the script.

This mechanism is described in PEP 397.

OTHER TIPS

To make sure that you are always running python 3, you can modify your Windows PATH Environment variable to include the python 3 directory, and remove the python 2 directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top