• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

What does #!/usr/bin/env python mean?

You've probably already seen one of the following lines:

#!/bin/sh
#!/usr/bin/env python
#!/usr/bin/env python3
#!/usr/bin/env python
#!/usr/bin/perl
#!/usr/bin/php
#!/usr/bin/ruby

This is a shebang. It's a directive for your command line interpreter how it should execute a script.

For example, you have a file with this content:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

print(sys.version_info)

Now you can execute it via python3 yourFile.py. But alternatively, you can make it executable and simply type ./yourFile.py

By the way, you should use #!/usr/bin/env python for some reasons.


Published

Apr 16, 2013
by Martin Thoma

Category

Code

Tags

  • Python 141

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor