Introduction to macOS and Python Versions
macOS has traditionally included Python 2.7 as the default version for several reasons, which we will explore in detail. This article aims to shed light on why macOS developers chose to include Python 2.7 and the challenges faced when moving to Python 3.
The Legacy Software Factor
Legacy Software: Many macOS system tools and applications were built using Python 2.7. At the time of its inclusion, Python 2.7 was widely used and supported, making it a stable choice for system-level scripts and utilities. This stability and widespread support allowed for seamless integration and deployment of these tools and applications.
The Transition to Python 3
Transition to Python 3: When Python 3 was released, it introduced several backward-incompatible changes. This means that existing Python 2 code would not necessarily run without modification. This complex transition made it difficult for developers and system maintainers to upgrade to Python 3 efficiently, thus prolonging the use of Python 2.7.
Stability and Compatibility
Stability and Compatibility: Python 2.7 had a long period of stability and was seen as reliable for existing applications. Apple likely chose to stick with it to avoid breaking existing workflows and applications that depended on it. This reliability helped ensure that critical system tools and software continued to function as expected without modifications.
The End of Life for Python 2
End of Life for Python 2: Python 2 reached its end of life on January 1, 2020. However, macOS versions released before that date still included Python 2.7. Apple has been gradually shifting toward Python 3 in more recent macOS versions. This transition takes time due to the extensive integration and dependency on Python 2.7 within the macOS ecosystem.
macOS Catalina and the Move to Python 3
macOS Catalina (10.15): Starting with macOS Catalina, Apple began moving away from including Python 2.7 by default. The company encouraged users to install Python 3 via Homebrew or other package managers. This shift marks the broader community's transition to Python 3 as the standard version for development, reflecting a move toward a more modern and compatible language.
Why macOS and Linux Include Python 2.7
macOS and Linux both come with Python 2.7 pre-installed because Python is needed as a dependency for some pre-installed software packages. The primary reason is that Python 3 is not backward compatible. If the operating system only included Python 3, all existing codes written for Python 2.7 would break. This is why the operating systems must include version 2.7. It is also possible to have both versions of Python installed in the OS.
For a deeper understanding of why Python 3 is not backward compatible, refer to Why is Python 3 not backwards compatible.
Conclusion
macOS does not come with a later version of Python because of the legacy software, transition challenges, and stability concerns associated with Python 2.7. However, as the ecosystem evolves, the operating system is gradually moving towards incorporating Python 3, ensuring compatibility and modern development practices.