Mac使用brew安装FFmpeg需卸载Python的问题及安全解决办法咨询
Hey there, let's work through this issue carefully since you've had bad experiences with Python uninstalls before.
That error comes from Homebrew's dependency-checking logic. When trying to install FFmpeg, Homebrew detects a Python environment it doesn't recognize as being managed by itself—almost certainly the pre-installed Python 2.x that comes with macOS (since Mac relies on this for core system tools). Your brew-installed Python 3.6.5 is fine, but Homebrew's FFmpeg formula wants to use its own managed Python for dependencies, and it's conflicting with the system's default Python in your PATH.
Crucially: the error's request to "uninstall python first" refers to non-brew Python—but you must never uninstall macOS's built-in Python! That's what caused your system failure before, and it will break critical system utilities.
FFmpeg itself doesn't require Python to run. The Python dependency comes from optional helper tools or compilation dependencies in Homebrew's FFmpeg package. Any brew-managed Python version (including your 3.6.5) is fully compatible—you just need to make sure Homebrew uses your installed brew Python instead of the system one.
These steps avoid touching your system Python entirely:
Prioritize brew's Python in your PATH
Runbrew info pythonto get the installation path of your 3.6.5 (it’ll look like/usr/local/Cellar/python/3.6.5_1). Add itsbindirectory to the top of your shell config file (~/.zshrcfor Zsh,~/.bash_profilefor Bash):export PATH="/usr/local/Cellar/python/3.6.5_1/bin:$PATH"Save the file and run
source ~/.zshrc(or your shell's corresponding file) to apply the change. This ensures Homebrew picks your brew-installed Python first.Fix brew's Python linking
Sometimes brew's Python might not be properly linked as the default for brew tools. Run this safe command to correct it:brew link --overwrite pythonThis only affects brew-managed software, not macOS's system Python.
Install FFmpeg with explicit Python path
If the above doesn't resolve the conflict, tell Homebrew exactly which Python to use during installation:HOMEBREW_PYTHON=/usr/local/bin/python3 brew install ffmpegConfirm
/usr/local/bin/python3points to your brew 3.6.5 first withwhich python3.Diagnose brew issues with
brew doctor
Runbrew doctorand look for Python-related warnings. Follow its specific fixes, but ignore any prompts to uninstall the system's built-in Python.
Never uninstall macOS's pre-installed Python! It powers core system tools, and removing it will break your OS. Only manage Python versions installed via Homebrew or tools like pyenv (which is also safe for multiple Python versions).
内容的提问来源于stack exchange,提问作者momo

