Reputation: 12649
Is there a way I can have multiple shebangs?
So I can call #!/usr/bin/env python3
on Ubuntu, but MacOS doesn't seem to have an equivalent, and I would like to call #!/usr/bin/python3
instead on it.
So is it possible to do something like:
#!/usr/bin/env python3
#!/usr/bin/python3
Upvotes: 8
Views: 5183
Reputation: 42999
We can't have multiple shebang lines - there can only be one and it should always be the first line.
If you need to support multiple versions of Python based on OS, it is best to write a small shell wrapper that invokes your python script with the right interpreter, probably with an exec
.
macOS does have /usr/bin/env
.
See this post:
Upvotes: 13