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

MacOS High Sierra下brew管理的Python3消失且无法重装求助

Fixing Disappeared Python3 & Protecting Python2 After Homebrew Update on macOS High Sierra

Hey there, let's troubleshoot this Python + Homebrew issue you're facing—this kind of Python3 disappearance after a brew update is actually pretty common, so let's break it down step by step.

Step 1: Diagnose Your Current Python Environment

First, run these commands to get a clear picture of what's going on:

  • Check where your default Python is located: which python
  • Try locating Python3: which python3
  • List Python-related packages installed via Homebrew: brew list | grep python
  • Verify installed versions:
    python --version
    python3 --version
    

Step 2: Restore Your Missing Python3

Most likely, the issue is broken symlinks from the Homebrew update. Follow these steps to fix it:

  1. Clean up old Python cache and unused files first:
    brew cleanup python
  2. Try reinstalling Python3 explicitly:
    brew install python3
    If you get a message saying Python3 is already installed but you still can't access it, the symlinks are probably messed up. Fix that with:
    brew link --overwrite python3
    • If you hit a permission error, fix Homebrew's directory ownership first (avoid sudo unless absolutely necessary):
      sudo chown -R $(whoami) $(brew --prefix)
      Then re-run the link command.

Step 3: Keep Your Python2 Safe During Brew Operations

You don't need to worry about losing access to Python2 when running brew upgrade python—here's why:

  • The Python2 that came pre-installed with macOS High Sierra lives in /usr/bin/python, which is part of the system's core files. Homebrew never modifies or deletes files in system directories; it only manages packages in its own directory (usually /usr/local/bin).
  • Modern Homebrew's python formula defaults to Python3. If you ever need to install a separate Homebrew-managed Python2, you can use brew install python@2 (note: this package is archived, so you might need to run brew tap homebrew/core first to access it). But the safest way to use your original Python2 is to call it explicitly with /usr/bin/python instead of just python, which avoids conflicts with Homebrew's Python3.

Bonus: Avoid Future Version Conflicts

If you regularly switch between Python versions, using pyenv is a great way to manage them without messing with system or Homebrew defaults:

brew install pyenv
# Install specific versions you need
pyenv install 2.7.18
pyenv install 3.11.x # Replace with your preferred Python3 version
# Set a default global version
pyenv global 3.11.x

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 09:03:10