I'm new to python. I've installed both Python 3.2.2 for x64 and Python 2.7 for x86 on my 64-bit windows machine. I've got some python code that are coded for python 2.x versions. But every time I try to run them by double clicking it is interpreted by python 3.x.
How do I force them to use python version 2.7, may be using some directives or using a BATCH script?
Going forward, the solution is to upgrade Python 3.2 to 3.3 or later and use the Python Launcher for Windows.
At the top of each Python 3 program, include the following line:
#!/usr/bin/env python3
At the top of each Python 2 program, include the following line:
#!/usr/bin/env python2
The #! part, called a shebang, indicates to Python Launcher which version of Python is desired. (It also indicates to UNIX that a program should be run with a particular interpreter instead of the shell.) The /usr/bin/env part helps locate the Python interpreter on your PATH when you run a program on UNIX. If you don't plan on using anything but Windows, you can leave it out:
#! python3
[or]
#! python2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With