How to manage python shebang on mixed systems?

Weatherby,Gerard gweatherby at uchc.edu
Sun Nov 6 21:24:36 EST 2022



A possible solution is here.

https://superuser.com/questions/815323/can-i-have-a-conditional-shebang
________________________________
From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of jak <nospam at please.ty>
Sent: Sunday, November 6, 2022 2:51:10 PM
To: python-list at python.org <python-list at python.org>
Subject: Re: How to manage python shebang on mixed systems?

*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Il 06/11/2022 11:03, Chris Green ha scritto:
> I have a number of python scripts that I run on a mix of systems.  I
> have updated them all to run on python 3 but many will also run quite
> happily with python 2.  They all have a #!/usr/bin/python3 shebang.
>
> This works almost everywhere but there is one system where only
> python 2 is available (at /usr/bin/python).
>
> I don't have python 2 on any of the systems I manage myself now so a
> #!/usr/bin/python shebang will fail.
>
> Is there a neat way of handling this?  I could write a sort of wrapper
> script to run via the shebang but that seems overkill to me.
>

hi,
If you can call Python from the shell prompt, then you could remove the
path from shebang:

#!python

--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!ke_gwJrnkkPx4fdk8CkLm6Qd2lmYIl7st4qz7Mmn0G8BerBOEwRWBfm51eFZ-Ut4WCTXTGoUEP5MTWYjmZE$


More information about the Python-list mailing list