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

Mac使用Homebrew升级Python3.6.5后,旧版本3.4路径残留报错

Fixing Python 3 Path Issue After Homebrew Installation on Mac

Hey there, let's work through this path problem step by step—it's a super common hiccup when upgrading Python with Homebrew, so we'll get it sorted without needing to download from the Python website.

The error you're seeing means your shell is still clinging to the old Python 3.4 path that no longer exists, even though Homebrew installed 3.6.5 correctly. Here's how to fix the root cause:

  • Clear your shell's command cache first
    Bash stores paths of recently run commands in a hash table to speed things up. Sometimes it holds onto the old Python 3 path even after you've installed a new version. Run this command to reset the cache:

    hash -r
    

    Now try python3 --version again—this might fix it immediately.

  • Check and update your PATH environment variable
    Homebrew installs Python 3 to /usr/local/bin/python3, but if your PATH lists the old Python framework directory (/Library/Frameworks/Python.framework/Versions/3.4/bin) before /usr/local/bin, your shell will still look there first.

    1. Run echo $PATH to see your current path order. /usr/local/bin should appear near the start.
    2. If it doesn't, open your shell config file (usually ~/.bash_profile for bash) in a text editor:
      nano ~/.bash_profile
      
    3. Add this line at the top to prioritize Homebrew's binaries:
      export PATH="/usr/local/bin:$PATH"
      
    4. Save and exit (in nano, press Ctrl+O, hit Enter, then Ctrl+X), then reload the config:
      source ~/.bash_profile
      
  • Check for invalid aliases
    You might have an alias forcing python3 to point to the old 3.4 version. Run this to check:

    alias python3
    

    If you see output like alias python3='/Library/Frameworks/Python.framework/Versions/3.4/bin/python3', remove that alias:

    1. Open your shell config file (same as above: ~/.bash_profile or ~/.bashrc)
    2. Delete the line starting with alias python3=
    3. Reload the config with source ~/.bash_profile
  • Re-link Homebrew's Python 3
    Sometimes Homebrew's symlinks get messed up, making python3 point to the wrong place. Fix the symlinks with these commands:

    brew unlink python3
    brew link python3
    

    If you hit a permission error, add sudo before the brew link command (though Homebrew usually doesn't require this if your /usr/local permissions are set correctly).

  • Restart your terminal
    If none of the above work, close and re-open your terminal. This ensures all config changes and cache resets take full effect.

After trying these steps, python3 --version should show Python 3.6.5 as expected.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:05:50