How to upgrade Python version on Mac
Python is one of the most popular scripting languages used on any platform, including Mac. It’s used for everything from coding websites to scraping data for analysis and building complex infographics and artificial intelligence tools like Stable Diffusions. Apple used to include a version of Python with macOS, and you could access it in the Terminal app. However, it stopped doing that when it launched macOS Catalina. If your Mac is running Catalina or an older version of macOS, you’ll have an old version of Python. In this article, we’ll show you how to upgrade Python on your Mac. And the good news is that if you have a newer version of macOS that doesn’t have Python installed, you can use the same method to install it for the first time.
Why upgrade the Python version on your Mac?
The main reason for upgrading Python is that each new version adds new features, improved compatibility, and better security. So, even if you don’t use Python regularly, it’s a good idea to upgrade to the latest version.
How to check which version of Python is on your Mac
If you’re not sure which version of Python, if any, is on your Mac, there’s an easy way to check it.
Go to your Applications folder > Utilities and open Terminal. Then, follow the steps below:
- Type: python --version
- Press Return.
- If Python is installed, you will see a message telling you which version.
- If it’s not installed, you will see command not found: python
How to upgrade the Python version on your Mac
The easiest way to upgrade the Python version on your Mac is to download the latest version from python.org and use the installer.
- In a web browser, navigate to the Python website.
- Underneath ‘Download the latest version for macOS,’ click Download Python.
- When the installer has downloaded, double-click it.
- Click Continue.
- Follow the instructions on the screen to install Python.
- When the installation has finished, go to the Python folder in your Applications folder.
- Double-click IDLE to open it (you will need to agree to allow it to access your Documents folder).
- At the top of the screen, you will see the version of Python that was installed.
How to upgrade Python using Terminal
The easiest way to upgrade Python using Terminal is to use Homebrew. Homebrew is a package installer and can be used to install lots of different packages in Terminal.
If you’ve already installed Homebrew, you can skip the steps below. If not, follow them to install it:
- Go to Applications > Utilities and launch Terminal.
- Paste this command in Terminal: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Press Return.
- Type in your admin password and press Return.
- Press Return when requested in the Terminal window.
- Wait for Homebrew to install.
Once Homebrew is installed, you can upgrade Python.
- Paste this command in Terminal: brew install python
- Press Return.
- Wait for Python to install.
- Once it has installed, you can use the new version of Python with this command: python 3
How to use Python on Mac
You can execute Python commands in Terminal once you’ve installed it. However, if you want to do more than execute the odd line of code, you’re much better off using a specialist application called an integrated development environment or IDE. Until recently, one of the best options for using an IDE on Mac was Microsoft’s Visual Studio. However, Microsoft announced that it will no longer develop Visual Studio for Mac, so the best option is now Apple’s own Xcode IDE. If you don’t want to install Python on your Mac, you can still write, test, and execute code in a web browser using Google’s Colab notebooks.
Python is a widely used scripting language and very useful for a number of tasks. It’s also a great language to learn as an introduction to coding. If you have Python installed on your Mac and think that it may not be the latest version, you should upgrade it to make sure you have access to the newest features and improvements. Follow the steps above to check which version, if any, is installed on your Mac and upgrade Python.