Back in 2019, Apple announced its plans to deprecate the Python 2.7 scripting language. With the release of macOS Monterey, Apple made good on that promise. macOS devices that are on versions 12.3 and above will no longer be able to execute scripts and operations that run on Python 2.7.
Why doesn’t Apple want their clients to use Python 2.7?
At first glance, this move may come off as quite unreasonable, as 53% of respondents from a survey say that their companies have no end-of-life (EOL) plan at all for shifting from Python 2.7.
If Python 2.7 is still so popular among the community, then why is Apple adamant about deprecating this version? Well, that’s where the story gets interesting.
The reason behind the move
The Python Software Foundation (the community that develops and maintains the Python codebase) originally released Python 2 way back in 2000. Although it was a revolutionary language, this version required significant changes, improvements, and bug fixes. And so, in 2006, Python 3 was released.
However, a huge portion of developers and companies that already began implementing Python 2 into their operations, weren’t ready to make the change, and mandating them to make the sudden shift from this language would ultimately hurt the Python community more than it helped them.
Which is why, the foundation decided to give developers ample time, and scheduled to sunset Python 2 in 2015.
“There are improvements Python 2 can’t handle. And we have less time to work on making Python 3 better and faster.”
– Python Software Foundation
However, even after 2015, Python 2 was still being extensively used by developers, and hence, the deadline was extended till 2020. On 1st January 2020, the Python Software Foundation officially sunset Python 2.
Sunset? What does that mean?
As of January 1st, 2020, no new bug reports, fixes, or changes will be made to Python 2. Even if vulnerabilities are discovered in Python 2, they will no longer be recognized or fixed.
Now you realize why Apple doesn’t want its users to develop software on Python 2.7. As a company that made its mark by offering the highest levels of security and privacy, it would be an outright contradiction of their key principles if Apple decided to continue support for Python 2.7.
Hence, in June 2019, Apple announced it was deprecating the Python 2.7 programming language and in April 2022, they removed support for Python 2.7 on macOS devices running Monterey 12.3 and above.
What does this mean to the day-to-day Mac user?
For the ordinary Mac user, this means that if they run a software or script that calls on the Python 2.7 interpreter, they’re either greeted by a warning message, or a complete script failure.
- On macOS 12.0.1 and above, up to macOS 12.3, if a software or program calls on the Python 2 interpreter to perform operations, the user would receive a warning stating that the app or program specified will not work with future versions of macOS and that it needs to be updated.
- On macOS 12.3 and above, apps and software that call on Python 2.7 will fail because the Python 2 interpreter will not be available on the Mac.
But what about apps and scripts that use the Python 3 runtime? Here too, users may encounter a slight hiccup. At least, during the first run.
Python 3 does not come automatically installed on macOS devices (even on those above versions 12.3). Hence, if the user tries to run a software, app, or script that calls on Python 3, a notification is triggered, which prompts the user to install XCode and developer tools.
After successful installation of the above tools, the app, software, or script will run on the Mac.
Now that we’ve discussed the issues, notifications, and warning messages an end-user may encounter, let’s talk about the IT side. Because this is where the real fiasco begins.
What does this mean for the IT admin?
For IT admins, Apple’s move away from Python 2.7 signifies that it’s time for them to wave goodbye to the old language and begin replacing all the scripts, software, and operations that were built on Python 2 with Python 3.
This is by no means a simple undertaking. Python 3 is not backwards compatible. Hence, one simply cannot replace the old Python 2 runtimes with the newer versions and expect everything to be business as usual.
Moreover, Python 3 includes several substantial changes from its predecessor (which is partly the reason why the Python developers have been pressing the community for this change), and hence, replacing the scripts and code may require contacting the developers of each software or app and requesting the updated version of the scripts.
What’s the solution?
The solution is to fully assess your company’s infrastructure, identify the software and scripts that use the deprecated language, and perform the necessary changes. You may also need to educate your end-users, guide them through the process, and resolve any issues they may report.
It’s going to be a long journey. Nevertheless, it is one that must be taken.
The first step involves identifying the scripts and software your company has deployed to their end-users that are dependent on Python 2.7.
The time taken to complete this step strictly depends on your company’s approach to managing and distributing scripts. If your company does not have a proper script organization and source control strategy in place, the process of inspecting each deployed script may prove to be… well, to put it lightly, inconvenient.
- You may scan for files that end in .py, or check if they have #!/usr/bin/python or #!/usr/bin/env python on the first line.
- You may reach out to your third-party vendors to verify that their software and products are updated to run on Python 3, and if not, request them to update ASAP.
- There are also a number of third-party packages available (some of them developed by individuals) that can transverse your directory and identify scripts that call on Python 2.
- If you use Hexnode to store and deploy scripts, you can easily review the custom scripts you’ve deployed, identify deprecated scripts, update them to the latest versions, and re-deploy them to end-users’ Macs.
Another idea would be to set up a test Mac that runs on a version of macOS 12.3 and to run it through your deployment. You can make a note of any prompts you receive, and confirm that each app, software, and script run as expected when Python 2 is not installed.
Break the news
As a responsible IT admin, you also need to let your end-users know that you’re upgrading their devices to macOS 12.3, and as a result, they may see reports of error message, or programs not working as expected.
Your IT team must,
- Educate your users of how you’re switching to Python 3.
- Inform them about the potential notifications they may receive on their Macs.
- Explain how you plan to remediate issues and distribute updated software.
You should also maintain a system to let users report any issues they may encounter during the switch, and enforce measures to appropriately organize and address these issues.
Install Python 3 on Mac
You should know that Python 3 doesn’t come installed on macOS by default. Although there is a stub located at /usr/bin/python3, calling this will simply trigger the notification to install Xcode and developer tools on the Mac (as mentioned earlier).
Hence, if you wish to use Python 3 on endpoints, you’ll have to deploy it yourself. The good news is, there are several options for doing so.
- You can download the software from python.org.
- You can install it using Xcode command-line tools.
- If your macOS devices have Homebrew installed, you can employ its help to install Python 3.
- You can use Hexnode UEM to deploy and configure Python 3 on all your end-user devices with just one-click (saves the most time).
Update the scripts
Once you’ve identified the scripts that run on Python 2.7, it’s time to update them. In the case of third-party software and scripts, the best solution is to contact the developers and request for the update.
The Python Software Foundation has also released a detailed document that list out everything developers should know when porting Python 2 code to Python 3.
Moreover, you can also employ the help of third-party tools like 2to3, Futurize, and Modernize, to help automate the conversion process.
The final note
Yes. The move from Python 2 to Python 3 will be a tough one. Be it developers, IT admins, or end-users, everyone will have a role to play in this conversion. However, with the help of the right tools and software, it is possible to streamline this process and ensure a speedy and pleasant conversion.
On top of its suite of advanced device management capabilities, IT admins can use Hexnode UEM to streamline the deployment of Python 3 on end-user devices, and ensure that all the apps, software, and scripts that companies may require, are updated to their latest versions.
Need help managing Mac devices?
Give Hexnode a go! Streamline the management of macOS devices in the enterprise using Hexnode's Unified Endpoint Management solution.TRY FOR FREE
Share your thoughts