Just a quick one this time. I needed a newer version of Python on my Mac. This article provides a very exhaustive explanation of what to do. When following its advice, I got into a mess with Homebrew. Basically, it needed to be updated, upon which it required changing the ownership of /usr/local:
$ brew update
Error: /usr/local is not writable. You should change the ownership and permissions of /usr/local back to your user account:
sudo chown -R $(whoami) /usr/local
I didn’t want to mess around with this, and I figured that it was time to reinstall Homebrew anyway. And yes, it solved the problem.
Here’s a quick digest of the above article and Homebrew’s Github page, which contains the uninstall and install scripts.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)" $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" $ brew install pyenv $ pyenv install --list $ pyenv install 3.8.3 $ pyenv global 3.8.3 $ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
So, the above reinstalls Homebrew (which can be useful if you’re running something hopelessly old), and then it installs Python 3.8.3. Since the last line writes to .bashrc, a new shell is required.