Mac下brew update遇Permission denied错误,求非sudo方案及Python3替代安装法
Hey there, let's work through this issue together—no sudo required, promise!
First: Fix the Brew Permission Issue
The error you're hitting happens because your user account doesn't have the right permissions to create or access /usr/local/Frameworks. Here's how to fix it properly:
Create the Frameworks directory and set correct ownership
Run these commands in your terminal (thesudohere is only for a one-time ownership fix, not running brew itself):mkdir -p /usr/local/Frameworks sudo chown -R $(whoami):admin /usr/local/FrameworksRelink or reinstall Python3
Now try linking the formula again:brew link python3If that still fails, reinstall Python3 with brew:
brew reinstall python3Fix broader /usr/local permission issues (if needed)
Sometimes other subdirectories in/usr/localmight have incorrect ownership too. Fix those with:sudo chown -R $(whoami):admin /usr/local/bin /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/etcThis ensures your user owns all the directories brew needs to operate, preventing future permission headaches.
Alternative Ways to Install Python3 on Mac (No Brew Needed)
If you'd rather skip brew entirely, here are reliable, hassle-free options:
Official Python Installer
Grab the installer for your desired Python version (3.6.5 in your case) directly from the Python official release page. It will automatically set uppython3andpip3in your system path, and install Python to/Library/Frameworks/Python.framework/.pyenv (For Version Management)
pyenv is ideal if you need to switch between multiple Python versions. Install it via git:git clone https://github.com/pyenv/pyenv.git ~/.pyenvThen add these lines to your shell config file (
.zshrcfor Zsh,.bash_profilefor Bash):export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)"Reload your shell with
source ~/.zshrc(or the appropriate file), then install Python 3.6.5:pyenv install 3.6.5 pyenv global 3.6.5 # Set this as your default system PythonMiniconda/Anaconda
Perfect for data science workflows—comes preloaded with popular scientific libraries. Download the lightweight Miniconda installer, run it, then usecondato manage your Python environment:conda create -n py36 python=3.6.5 conda activate py36
A quick note: Avoid running brew with sudo unless it's absolutely necessary. It causes files to be owned by root, which leads to ongoing permission issues like the one you're facing. Fixing directory ownership is the safe, recommended approach from the brew team.
内容的提问来源于stack exchange,提问作者joesan




