-
Notifications
You must be signed in to change notification settings - Fork 47
Home
Welcome to the python-for-network-enginners wiki!
In scripts, first line should specify the path to interpreter.
But on different servers Linux, Unix, or BSD this path could be different.
Why do some python scripts begin with #!/usr/bin/env python or #!/usr/bin/python?
#!/usr/bin/env python or #!/usr/bin/python plays a role if the script is executable.
The script calls the language's interpreter to run the code inside the script.
the shebang is the "guide" to find, in your example, python.
Using #!/usr/bin/env python instead of #!/usr/bin/python makes sure python (or any other language's interpreter) is found, in case it might not be in exactly the same location across different Linux- or Unix -like distributions.
Although #!/usr/bin/python will work on a default Ubuntu system, it is therefore good practice to use #!/usr/bin/env python instead.