1

Possible Duplicate:
Why do people write #!/usr/bin/env python on the first line of a Python script?

I am currently teaching myself Python and I have a question about python. In many examples of Python, I've seen the same line of code at the top:

#!/usr/bin/env python

My question is what purpose does the code above serve, and why is it necessary? So far, I've been practicing Python code without this line of code. If someone could explain this to me, it would help a lot. Thanks in advance.

Community
  • 1
  • 1
JaPerk14
  • 1,574
  • 2
  • 20
  • 32

2 Answers2

1

#!/usr/local/bin/env python

You are specifying the location to the python executable in your machine, that the rest of the script needs to be interpreted with. You are pointing to python is located at /usr/local/bin/python.

Python is not always installed at '/usr/local/bin/python'. You can also call different python versions by #!/path/to/your/python/version.

Daniel
  • 17,131
  • 7
  • 51
  • 70
0

It is describing the location of the python install that your code should use. See here and here.

Community
  • 1
  • 1
Fantastic Mr Fox
  • 27,453
  • 22
  • 81
  • 151