Recent releases of popular linux distributions have chosen to not install any python
command by default. This makes it incredibly difficult to write portable scripts that works on both older and newer systems.
The smelly options:
- rewriting the scripts at packaging or install time
- forcing the user to call the script specifically with the versioned python interpreter
- expecting the user will have run update-alternatives or similar
Is there a way to write a shebang #!
line that uses only generally installed standard linux standard tools and can run either python3
,python2
, or python
?
I want something like a fictional --choices
argument to the env
command
#!/usr/bin/env --choices python3,python2,python
But of course that doesn't exist.