There are many ways in which you can install Python on a Mac, directly from Python.org using dmg files or using the brew package manager.
Most macOS comes bundled with the latest version of Python 3.x as well as Python 2.7 and you may have installed others for your projects.
If you are wondering how to easily access these different versions using a Mac terminal, then the best way is to create an alias for them.
Based on which Terminal Shell you use, open the profile file ~/.bashrc or ~/.zshrc and add the aliases for different Python versions you have.
Example:# Alias for Python 2.7
alias python2='/usr/bin/python2.7'
# Alias for Python 3.8
alias python3.11='/Library/Frameworks/Python.framework/Versions/3.8/bin/python3'
# Alias for Python 3.9
alias python3.11='/Library/Frameworks/Python.framework/Versions/3.9/bin/python3'
# Alias for Python 3.11
alias python3.11='/Library/Frameworks/Python.framework/Versions/3.11/bin/python3'
Save and refresh the prompt and now you can easily access any Python version by simply using the. version number.

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to MacOS,
- How to Display Analog Clock on Mac Menu Bar
- Shutdown Mac Terminal Command
- How to know the Serial Number of MacBook on macOS Ventura 13.0
- macOS: Remove Desktop or Documents Folder from iCloud Drive Syncing
- [fix] How to Show file extensions on all files on Mac
- How to install Zoom Add-in to Outlook (Mac)
- How to turn off Stage Manager - macOS Ventura
- Fix - Xode - Internal logic error: Connection was invalidated
- How to do calculations in Mac Terminal
- How to delete a Page in Microsoft Word File on Mac (macOS)
- How to Refresh Mac Desktop
- How to install Java on macOS [Big Sur]
- How to Disable Mac Terminal Bell Sound
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to Uninstall Brew on Mac
- Find your macOS version
- Change TextEdit File Encoding
- AppleScript Example with TextEdit
- How to install homebrew (brew) on M1 Mac
- How to Find File and Directory Size in Mac Terminal
- How to open new tab in Sublime Text Editor [macOS]
- How to list all users in Mac Terminal
- Turn off Auto-Capitalization on macOS Ventura 13
- How to check Command Line Tools Version [Updated for Ventura]
- Change Current User Password using Mac Terminal Command
More Posts:
- Change CKEditor Table Properties default width - CKEditor
- Iterate over an Array using Java 8 Stream and foreach - Java
- How to take a screenshot of android emulator (AVD) screen - Android
- Python: Replace the First Occurrence of String in a String - Python
- How to Change Mac Computer and Localhost Name using Terminal - MacOS
- How to Save Jupyter Notebook as PDF - Python
- How to Turn off "Terminal" would like to access files message on Mac? - MacOS
- Capitalize the first letter of each word using Notepad++ - NotepadPlusPlus