Re:I just want to run this one Python script
by theon144 on Monday November 08, 2021 @12:41PM
(#29151872)
>Ever had a script that's compatible with both, Python 2 and 3...
The article is literally about this scenario, which is why I'm also confused. Yes, `/usr/bin/env python` is a bad idea IF your script depends on a certain version, but that's exactly what the author doesn't need!
Re:I just want to run this one Python script
by Dunedan on Monday November 08, 2021 @04:29PM
(#29154528)
> I believe that Debian based systems link to some version of Python 2.
Since Debian 11 and Ubuntu 20.04 LTS it's a matter of installing the matching package:
python-is-python2 [1] for having /usr/bin/python link to Python 2.7, python-is-python3 [2] for having /usr/bin/python link to Python 3.x or none of them to avoid having /usr/bin/python at all. The latter one will still result in a working system, as all Python scripts shipped by Debian/Ubuntu nowadays explicitly specify /usr/bin/python2 or /usr/bin/python3.
Re:I just want to run this one Python script
by jfrunyon on Monday November 08, 2021 @04:33PM
(#29154554)
Oh god. No, not having a `/usr/bin/python` will not result in a working system. Does Debian really think they're the only software distributor that their users use?
Re:I just want to run this one Python script
by teddyh on Tuesday November 09, 2021 @08:32AM
(#29161467)
No, which is why the “python-is-python2” and “python-is-python3” packages exist.
Re:I just want to run this one Python script
by jfrunyon on Thursday November 11, 2021 @08:34PM
(#29195397)
Great! Except that apparently, you can have neither of those packages installed.
Re:I just want to run this one Python script
by kevinmgranger on Monday November 08, 2021 @08:46AM
(#29149202)
> I don't know why you would want to use these contrivances to simply give preference to Python 3.
Performance gains, preferring future-looking development, and better error messages.
Of course, if your script will run under both Python 2 and 3, I don't know why you would want to use these contrivances to simply give preference to Python 3.