I'm trying to find the best way to switch between the two python compilers 2.7 to 3.3 If I run python from cmd, I would you use something like
python ex1.py
where I set "python" from window environment variable from my computer properties to point to either python 3.3 or 2.7 one or another.
I am wondering there is an easy way to switch between the two from cmd line ?
For Windows 7, I just rename the
python.exe
from the Python 3 folder topython3.exe
and add the path into the environment variables. Using that, I can executepython test_script.py
and the script runs with Python 2.7 and when I dopython3 test_script.py
, it runs the script in Python 3.To add
Python 3
to the environment variables, follow these steps -Properties
.Advanced System Settings
.Environment Variables
and editPATH
and add the path to your Python 3 installation directory.For example,
You can try to rename the python executable in the python3 folder to python3, that is if it was named python formally... it worked for me
No need for "tricks". Python 3.3 comes with PyLauncher "py.exe", installs it in the path, and registers it as the ".py" extension handler. With it, a special comment at the top of a script tells the launcher which version of Python to run:
Or
From the command line:
Or
See 3.4. Python Launcher for Windows
They are 3 ways you can achieve this using the py command (py-launcher) in python 3, virtual environment or configuring your default python system path. For illustration purpose, you may see tutorial https://www.youtube.com/watch?v=ynDlb0n27cw&t=38s