Tidying up Python

Bill Cole macportsusers-20171215 at billmail.scconsult.com
Fri Jul 11 14:48:51 UTC 2025


On 2025-07-11 at 05:51:09 UTC-0400 (Fri, 11 Jul 2025 04:51:09 -0500)
Ryan Carsten Schmidt <ryandesign at macports.org>
is rumored to have said:

> On Jul 11, 2025, at 04:04, Bjarne D Mathiesen wrote:
>>
>>> I believe I read somewhere that the python community recommends that 
>>> "python" always be python 2.x, never python 3.x. Programs that want 
>>> to use python 3.x should use the program name "python3". If "port 
>>> select python" currently allows versions of python 3.x to be 
>>> selected, we may want to change that.
>>
>> We did do a concerted effort in getting rid of python27 in macports 
>> some
>> time back. If I remember correctly, I had a major part in updating a 
>> lot
>> of stuff to at least python35 at that time.
>>
>> Python27 is offically dead. It was only being kept around in a 
>> comatose
>> state because of a lot of stuff not having been upgraded to python3.x
>
> None of that contradicts what I wrote. Any program running "python" 
> expects it to be python 2.x. Don't make "python" be python 3.x or you 
> will break those programs.
>
> At least, that was the wisdom I gleaned last time I looked this up 
> some years ago. If the position of the python community has changed 
> since then, please provide a citation.

  I cannot speak for the Python community, but evidence supports that 
having changed.

FreeBSD (since 12?) no longer includes any python in the base install, 
2.7 is still in ports (because there are dependents with constituencies) 
and there are 3 version of python3 in ports. None of them install a 
simple 'python' binary or link.

On EL9-based systems 'python' means python3:

	[bcole at gitlab ~]$ ls -l /usr/bin/python
	lrwxrwxrwx. 1 root root 9 Dec 12  2024 /usr/bin/python -> ./python3
	[bcole at gitlab ~]$ ls -l /usr/libexec/platform-python
	lrwxrwxrwx. 1 root root 18 Dec 12  2024 /usr/libexec/platform-python -> 
/usr/bin/python3.9
	[bcole at gitlab ~]$ head /etc/os-release
	NAME="AlmaLinux"
	VERSION="9.5 (Teal Serval)"
	ID="almalinux"
	ID_LIKE="rhel centos fedora"
	VERSION_ID="9.5"
	PLATFORM_ID="platform:el9"
	PRETTY_NAME="AlmaLinux 9.5 (Teal Serval)"
	ANSI_COLOR="0;34"
	LOGO="fedora-logo-icon"
	CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"


Ubuntu 22 (like its Debian base) has no Python by default but it does 
provide hints:

	bcole at www:~$ python --version
	Command 'python' not found, did you mean:
	  command 'python3' from deb python3
	  command 'python' from deb python-is-python3


macOS is a special case. The XCode CLT package installs a version of 
Python3 that it links to /usr/bin/python3. As of SDK14 it includes a 
python-config script that expects '/usr/bin/python ' to be python2, 
which it is not true on any macOS 14 machine as configured by Apple. 
What this indicates is 'correct' is beyond my capacity to discern. 
Obviously nothing that actually works correctly  in the base system can 
depend on a 'python' link or binary existing at all

HOWEVER, unless one is using macOS 14 or later, I would not depend on it 
being safe to have a 'python' link in the default $PATH that points to a 
Python 3.x executable.





-- 
  Bill Cole
  bill at scconsult.com or billcole at apache.org
  (AKA @grumpybozo at toad.social and many *@billmail.scconsult.com 
addresses)
  Not Currently Available For Hire


More information about the macports-users mailing list