1

How do I confirm my shebang line worked for python? I'm on a windows machine.

My default python is python3.3 but I would like to use python2.7 for my current script. How do I know if the shebang worked? This is my quick code to attempt to confirm

#!/usr/bin/python2.7.6
import sys

print (sys.version)

However, I am being told that I'm still on python3.3. I know this is simple but I haven't found anything that can quickly answer my question.

irrelephant
  • 4,091
  • 2
  • 25
  • 41
RocketTwitch
  • 285
  • 5
  • 17

1 Answers1

2

Shebang lines are a Unix-ism, not a Windows thing. On Windows you will need to launch your script with the correct interpreter. One idea would be to change the file extension to .py2 and then associate that with the Python 2 interpreter.

You can also look at PEP 397, which describes a new launcher in Python 3.3 which can locate other Python interpreter versions according to your shebang line. This is a Python 3.3 feature, not a Windows one, just to be clear.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436