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!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- How to show line numbers in Nano on Mac
- How to install Jupyter Notebook on macOS Sonoma
- How to Disable Remote Management using Mac Terminal
- Test internet speed using macOS Terminal command
- Docker Desktop needs privileged access macOS
- Google Search Hot Trends Screensaver for Mac OS X
- How to do calculations in Mac Terminal
- How to make TextEdit the default text Editor on Mac
- How to Show Full Website Address on Safari for Mac (Ventura/Sonoma)
- The Zsh Shell - Mac Tutorial
- Opening mac Terminal
- How to change the name of your Mac running on macOS Ventura 13
- How to find the Battery Cycle Count on macOS Ventura
- How to set an emoji as Zsh terminal prompt in macOS
- How to access Trash Folder using Mac Terminal Command
- macOS Ventura XCode Command Line Tools Installation
- Hide Bluetooth icon on Mac Menu Bar macOS Ventura 13
- How to run .sh file in Mac Terminal
- Terminal Command to get the list of available shells in macOS
- How to see Storage Information on macOS Ventura
- How to Go To /usr/local/bin on Mac Terminal?
- How to do screen recording on Mac
- How to Find File and Directory Size in Mac Terminal
- Open .bash_profile File in TextEdit using Terminal
- Remove Now Playing icon from macOS Big Sur Menu Bar
- How to Stop Photos App from auto loading when device connected to the Mac - Mac-OS-X
- How to remove Spring Boot Text Banner shown in Console when Application Starts - Java
- Fix Error 2711 SQL RBS client - The installer has encountered an unexpected error. The specified Feature name ('Docs') not found in Feature table - SharePoint
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash] - Linux
- PowerShell: Check if File Exists - Powershell
- bash: cls: command not found - Linux
- Upload docx file using PHP script - PHP
- Fix NVIDIA GeForce Experience ERROR CODE 0x0003 - HowTos