How to install Python on macOS Catalina using homebrew

catalinahomebrewpython

I'm trying to install Python 3 in macOS Catalina (10.15.3 (19D76)) using homebrew but it is giving the below error:

dmanna-a01:operations dmanna$ brew install python3
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.6_1.catalina.bottle.tar.gz
Already downloaded: /Users/dmanna/Library/Caches/Homebrew/downloads/d5d5e7ec237016a2c35d66ddbe2edfa461d9fa20da5cad2ad3ffeb08f6d87bae--python-3.7.6_1.catalina.bottle.tar.gz
==> Pouring python-3.7.6_1.catalina.bottle.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

Brew Version

dmanna-a01:operations dmanna$ brew -v
Homebrew 2.2.5
Homebrew/homebrew-core (git revision 028f1; last commit 2020-02-10)

Best Answer

chown the usr/local directory:

sudo chown -R $(whoami) /usr/local

Then try to install python3 again and it should work:

brew install python3

OR,

You can try this also if the above solution didn't help

sudo chown -R $(whoami) $(brew --prefix)/*

Reference: https://gist.github.com/irazasyed/7732946