2 ms·
> but then you have to add a shebang line directly to the script itself, which I always feel uncomfortable since it's hard-coded It won’t directly help reach y
by Someone 2y ago
> but then you have to add a shebang line directly to the script itself, which I always feel uncomfortable since it's hard-coded
It won’t directly help reach your goal, but it is semi hard-coded. The ‘correct’ (but see https://unix.stackexchange.com/a/29620 https://unix.stackexchange.com/a/29620 for some caveats) way to write a shebang line is
#!/usr/bin/env python
That will make it run the first python in your path.
> what if in future I don't want to execute my .py script with `/usr/bin/python` but `/usr/bin/nohtyp`?).
You could create a symlink called python to /usr/bin/nohtyp on your system in a directory that’s searched before /usr/bin (e.g. by adding ~/myCommandPreferences to the front of your PATH)
- erik_seaberg 2y agoTo be excruciatingly correct, we should specify python2 or python3, because they can't interop and probably never will.
- skeledrew 2y agoI think at this point we can rest easy that python2 has finally been fully purged from default installs. Heck a few weeks ago I installed Kubuntu 24.04 base and there was no Python at all...
- erik_seaberg 2y agoDebian stable doesn't have "python" anywhere on my PATH, for a good reason IMHO. Shebangs say "/usr/bin/env python3" or hardcode "/usr/bin/python3".