You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python IDLE与HomeBrew更新后Python版本不一致问题咨询

Why python3 Shows Older Version After Homebrew Update?

Hey there! I totally get the confusion—you’ve updated Python via Homebrew to 3.6.4_4, but your terminal still shows 3.5.2 when running python3 --version. Let’s break down why this is happening and how to fix it.

The Root Cause

This almost always comes down to your system’s PATH environment variable. When you run a command like python3, your Mac searches through directories listed in PATH in order—whichever directory has the matching executable first gets used.

  • The Python you installed from the official website is likely in a directory that appears before Homebrew’s Python directory in your PATH.
  • Homebrew typically installs Python in /usr/local/bin (for Intel Macs) or /opt/homebrew/bin (for Apple Silicon Macs), but if your PATH prioritizes the older install’s location (like /Library/Frameworks/Python.framework/Versions/3.5/bin or /usr/bin), that’s why you’re still seeing the 3.5.2 version.

Step-by-Step Fixes

1. Verify Current python3 Path

First, check exactly which python3 your terminal is using:

which python3

The output will show the full path to the executable (e.g., /Library/Frameworks/Python.framework/Versions/3.5/bin/python3), confirming it’s the old version.

2. Locate Homebrew’s Python Path

Next, find where Homebrew installed your updated Python:

brew info python

Look for lines like Executable:/usr/local/bin/python3.6—this is the path to your newer 3.6.4_4 version.

3. Adjust Your PATH to Prioritize Homebrew

You need to add Homebrew’s bin directory to the start of your PATH so it gets checked first.

  • If you’re using Zsh (default on macOS Catalina and later), edit your ~/.zshrc file:

    nano ~/.zshrc
    

    Add this line at the top:

    # For Intel Macs
    export PATH="/usr/local/bin:$PATH"
    
    # For Apple Silicon Macs
    # export PATH="/opt/homebrew/bin:$PATH"
    

    Save the file (Ctrl+O, then Enter) and exit (Ctrl+X). Then apply the changes:

    source ~/.zshrc
    
  • If you’re using Bash, edit ~/.bash_profile or ~/.bashrc instead, using the same PATH line, then run source ~/.bash_profile.

4. Verify the Fix

Run python3 --version again—you should now see the Homebrew-updated 3.6.4_4 version.

Bonus: Use Homebrew’s Link Command (If Needed)

If adjusting PATH doesn’t work, you can force Homebrew to link its Python as the default:

brew link --force python

Note: Run brew link --dry-run python first to preview changes and avoid accidental conflicts.


内容的提问来源于stack exchange,提问作者user9141560

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:59:55