There are two recommended ways to install Python: one is to use the official installation package, which is suitable for novices; the other is to use Homebrew, which is suitable for developers. The first method is to go to the Python official website to download the macOS installation package (.pkg file), double-click to install, enter python3 --version to verify the version in the terminal. This method has clear graphical interface guidance, and it is recommended to choose a stable version. The second method requires that Homebrew is installed first, and then run brew install python installation. The installation path is /usr/local/bin or /opt/homebrew/bin to avoid conflicts with the system's own version. You can check the path through which python and which python3. If you need to set the new version as default, you can temporarily run alias python=python3 or write it to the .bash_profile or .zshrc file for long-term effectiveness, and you can also use pyenv to manage multiple versions. Both methods should pay attention to version and path consistency to ensure normal use.
Python is a very commonly used programming language on Mac. Although the system comes with Python 2, most developers will install newer versions (such as Python 3.x). Let’s talk about the key points directly: The recommended way to install Python is through the official installation package or Homebrew, which is simple but not easy to make mistakes.

Download and install the official Python package
This is the most intuitive method and is suitable for new users who are just starting out.
- Go to the Python official website and click to download the latest version of macOS installation package (.pkg file).
- Double-click the downloaded installation package and follow the prompts to install it step by step.
- After the installation is completed, open the terminal and enter
python3 --version
to see if the installation is successful.
The advantage of this method is that the graphical interface is clear and there is no need to type a command. However, it should be noted that there may be differences between different versions, and it is recommended to choose a stable version instead of a preview version.

Install Python using Homebrew (for developers)
This method is faster if you have used Homebrew, a common package management tool on Mac.
- Make sure Homebrew is installed: run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Python: Run
brew install python
- Check version:
python3 --version
Homebrew will place newly installed Python in /usr/local/bin
or /opt/homebrew/bin
by default, so that it will not conflict with the system's own Python.

Note: Sometimes when you enter
python
in the terminal or call the old version, you can usewhich python
andwhich python3
to see if the path is correct.
Set the default Python version (optional)
If you want to directly enter python
, you can use the new version of Python, you can set aliases or modify environment variables.
- Temporary setting of aliases: Run
alias python=python3
in the terminal - Long-term effect: add the above sentence to your shell configuration file (such as
.bash_profile
or.zshrc
)
If you frequently switch multiple projects, you may want to consider using pyenv
to manage multiple Python versions.
Basically that's it. Not complicated, but paying attention to path and version issues are easy to ignore. As long as you make sure that the version of the installation source and terminal call is consistent, there will generally be no problem.
The above is the detailed content of How to install Python on Mac. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

If you're using a Mac with multiple monitors, you might be curious about how to display the Dock on all screens or whether it's possible to add a Dock to secondary displays.The good news is that you can configure the Dock to appear on any screen conn

Fortnite is once again available for iPhone and iPad users, bringing joy to many gamers. However, there's still no official version for Mac (at least not yet). Despite that, Apple Silicon Mac owners aren’t completely out of luck—you can run the iOS/i

If you've owned multiple Apple devices over the years, you might find yourself in a situation where some of those older Macs, iPhones, iPads, or other Apple hardware have been sold, given away, or traded. No matter how they left your possession, it's

iCloud Private Relay is an excellent privacy feature included with the iCloud subscription, designed to safeguard your online activity and browsing by masking your IP address (using a temporary one) and encrypting DNS lookups. This prevents third pa

Are you using Screen Time to manage your or your child’s Mac usage? If yes, you likely already know that it allows you to set app limits, schedule downtime on the Mac, and more. Additionally, you can also choose specific apps that remain accessible a

macOS Sequoia is a solid operating system that brings some impressive features like iPhone Mirroring, and while performance is excellent for many users, not everyone experiences the same level of speed. If you're finding macOS Sequoia slower than pre

If you frequently use iMessage, then you've likely shared numerous web links in your chats — maybe an article, a video, a tweet, a song, or anything else. Locating these links later can be quite frustrating, but thankfully there's a simpler method th

Advanced Mac users familiar with the command line can swiftly set up a MacOS Tahoe 26 beta virtual machine by entering a few commands into Terminal, using tart. Tart is a command-line utility for managing virtual machines and offers one of the quicke
