Most distros ship with python3 (though `python` will refer to python2).
Is there a reason you cannot just say `#!/usr/bin/env python3` in your scripts? I don't see why you require python3 to be the default, am I missing something here?
Came here to ask the same question. Under archlinux python 3 is the default, which breaks scripts who don't specify that their are python 2 only and start with #!/usr/bin/python and not #!/usr/bin/python2. But even there as user I don't see the need for this tool.
I think it's recommended for distros to modify the shebang to /usr/bin/env python3 for script that are supposed to run under python 3, although this does pose a problem for scripts that want to run under both without modification. If the distro ships with python3 and most of the system scripts run under python3 I'd say its the default.Ubuntu for one is planning on not shipping a python2 or /usr/bin/python binary by default(although it will still be in repos) eventually.
If you don't care which version of python it runs under, you do this:
#!/usr/bin/env python
If you do, then `python2` or `python3` will be around, and you should specify them explicitly instead of `python`. I'm happy to be corrected on this one, but I always slap this at the top of my scripts:
#!/usr/bin/env python3
I'm not aware of anywhere that wouldn't invoke a Python 3 interpreter if one is installed.
I think a number of distros include python3 by default, but -- per python's own standards (adopted as a result of disruption caused by Arch having python3 as /usr/bin/python -- it isn't linked to /usr/bin/python but to /usr/bin/python3; /usr/bin/python is (except on Arch) always python2. That's not a matter of which is "default python" (e.g., even if, as Ubuntu plans to, python3 is the only python installed (not merely "the default python"), it will only be /usr/bin/python3, not /usr/bin/python.)
This is about consistency given that major versions aren't intended to be backward compatible so scripts either fail or find a compatible python when using a shebang, not about what is "default".
When you have several Python programs, where does /usr/bin/python point to?
I must admit, that I did not think to much about it until now, but normally there is only /usr/bin/python in the scripts.
Of course, if everybody has /usr/bin/python3 inside his Python3 programs, everything could work (unless some of your apps need special environment vars like PYTHONPATH, what could make it troublesome again).
But still, the standard installation of Debian (and others, as much I know) does not include Python3 by default, you at least have to add it to your installation. That is something, you must tell your customers, when you ship Python3 programs.
The apps in question use a shebang of `#!/usr/bin/env python3`. I believe it is working as designed. This is a Fedora system, which switched to Python 3 a couple of revisions back. But, I would assume this would affect any system that has utilities that use that shebang.
Edit: Out of curiosity, I grepped for other system utilities that might have this quirk, and it seems like nearly all Python utilities call /usr/bin/python3 directly, but ten of them (on my system) use `env`. That might be a bug worth filing with the Fedora folks. I can't imagine they want it to act this way when a custom Python is installed. Though it's been that way for at least a couple of releases.
As a full time Arch user the change was a little annoying at first but now I am perfectly happy using Python3 as the default because all my Python shell scripts and system installed packages work under Python3. I can simply work in a Python2 virtualenv when I need python2.
Interesting, that's not recommended by python devs. Ubuntu follows the guideline of keeping /usr/bin/python as Python 2 (which will not be installed by default), and /usr/bin/python3 as Python 3.
If I can't make the executable, by default on installing, be 'python2', I'm adding quite a lot of pain to users (in particular, all those users with #!/usr/bin/env python2 in scripts).
I have no problem with Arch having a "only install python3 by default" rule. They can even not distribute python2 for all I care.
But, don't make /usr/bin/python run python3, that just confuses programs which have made the (reasonable based on past experience, and official python advice) assumption that it /usr/bin/python will run python2.
This has been a long time coming. Not being able to use Python3.x for web development was a large barrier for me switching completely. Now Python3.x just needs to be the default for more linux distros.
Is there a reason you cannot just say `#!/usr/bin/env python3` in your scripts? I don't see why you require python3 to be the default, am I missing something here?
reply