Having trouble installing Python3, please help

$ brew install python3

==> Downloading https://homebrew.bintray.com/bottles/python-3.7.7.mojave.bottle.

==> Downloading from https://akamai.bintray.com/cc/cc8177d823b39d099e1f1a6f2e0fc

######################################################################## 100.0%

==> Pouring python-3.7.7.mojave.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

Mojave 10.14.6

What does brew doctor say?

I did that and followed some of the procedures brew suggested.

Then I tried “brew install python3” again and got:

Updating Homebrew…
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
cpm jobber
==> Updated Formulae
angular-cli dvc nats-streaming-server
ask-cli exempi nspr
aws-cdk exploitdb phpstan
balena-cli hlint profanity
cfn-lint internetarchive source-to-image
cjdns jdupes terraform
clojure-lsp lean-cli vim
composer micro
convox micronaut

Warning: python 3.7.7 is already installed, it’s just not linked
You can use brew link python to link this version.

So then this happened:

Davids-MacBook-Pro-4:~ dg$ brew link python
Linking /usr/local/Cellar/python/3.7.7… Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework

What does ls -al /usr/local/* say?

It gives a very long list that starts like this:
/usr/local/Cellar:
total 0
drwxr-xr-x 62 dg admin 1984 Jun 24 17:08 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/Frameworks:
total 0
drwxr-xr-x 2 root wheel 64 Jun 25 09:09 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …

/usr/local/Homebrew:
total 112
drwxr-xr-x 20 dg admin 640 Jun 25 09:11 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
-rw-r–r-- 1 dg admin 51 Jun 24 16:23 .dockerignore
-rw-r–r-- 1 dg admin 380 Jun 24 16:23 .editorconfig
drwxr-xr-x 16 dg admin 512 Jun 25 09:12 .git
drwxr-xr-x 7 dg admin 224 Jun 25 09:11 .github
-rw-r–r-- 1 dg admin 7113 Jun 24 16:23 .gitignore
-rw-r–r-- 1 dg admin 65 Jun 24 16:23 .vale.ini
-rw-r–r-- 1 dg admin 219 Jun 24 16:23 .yardopts
-rw-r–r-- 1 dg admin 98 Jun 24 16:23 CHANGELOG.md
-rw-r–r-- 1 dg admin 831 Jun 25 09:11 CONTRIBUTING.md
-rw-r–r-- 1 dg admin 1698 Jun 24 16:23 Dockerfile
-rw-r–r-- 1 dg admin 1334 Jun 24 16:23 LICENSE.txt
drwxr-xr-x 9 dg admin 288 Jun 25 09:11 Library
-rw-r–r-- 1 dg admin 8278 Jun 25 09:11 README.md
-rw-r–r-- 1 dg admin 704 Jun 24 16:23 SECURITY.md
drwxr-xr-x 3 dg admin 96 Jun 24 16:23 bin
drwxr-xr-x 7 dg admin 224 Jun 24 16:23 completions
drwxr-xr-x 57 dg admin 1824 Jun 25 09:11 docs
drwxr-xr-x 5 dg admin 160 Jun 24 16:23 manpages

/usr/local/bin:
total 99832
drwxrwxr-x 457 dg admin 14624 Jun 25 09:10 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
-rw-r–r-- 1 dg admin 0 Jun 24 16:58 .keepme
lrwxr-xr-x 1 dg admin 31 Jun 25 09:10 2to3 -> …/Cellar/python/3.7.7/bin/2to3
lrwxr-xr-x 1 dg admin 35 Jun 25 09:10 2to3-3.7 -> …/Cellar/python/3.7.7/bin/2to3-3.7
-rwxr-xr-x 1 root wheel 8405280 May 23 2018 FAHClient
-rwxr-xr-x 1 root wheel 1350352 May 23 2018 FAHCoreWrapper
lrwxr-xr-x 1 dg admin 35 Sep 18 2016 abinit -> …/Cellar/abinit/8.0.7_3/bin/abinit
lrwxr-xr-x 1 dg admin 37 Jun 24 16:58 aclocal -> …/Cellar/automake/1.16.2/bin/aclocal
lrwxr-xr-x 1 dg admin 42 Jun 24 16:58 aclocal-1.16 -> …/Cellar/automake/1.16.2/bin/aclocal-1.16
lrwxr-xr-x 1 dg admin 32 Sep 18 2016 aim -> …/Cellar/abinit/8.0.7_3/bin/aim
lrwxr-xr-x 1 dg admin 35 Sep 18 2016 anaddb -> …/Cellar/abinit/8.0.7_3/bin/anaddb
lrwxr-xr-x 1 dg admin 31 Jun 24 16:59 annotate -> …/Cellar/gd/2.3.0/bin/annotate
lrwxr-xr-x 1 dg admin 71

[some entries omitted for brevity]

/usr/local/bin:
total 99832
drwxrwxr-x 457 dg admin 14624 Jun 25 09:10 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/etc:
total 8
drwxr-xr-x 12 dg admin 384 Jun 24 16:58 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/include:
total 1264
drwxrwxr-x 269 dg admin 8608 Jun 24 17:00 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/lib:
total 5264
drwxrwxr-x 296 dg admin 9472 Jun 24 17:00 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/man:
total 0
drwxr-xr-x 5 dg wheel 160 Apr 4 2019 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
drwxr-xr-x 4 dg wheel 128 Mar 30 2013 man1
drwxr-xr-x 929 dg wheel 29728 Mar 30 2013 man3
drwxr-xr-x 286 dg wheel 9152 Mar 30 2013 mann

/usr/local/octave:
total 0
drwxr-xr-x 3 dg wheel 96 Apr 4 2019 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
drwxr-xr-x 12 root admin 384 Sep 18 2016 3.8.0

/usr/local/opt:
total 0
drwxr-xr-x 74 dg admin 2368 Jun 25 09:12 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/remotedesktop:
total 0
drwxr-xr-x 3 root wheel 96 Apr 4 2019 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
drwxr-xr-x 3 root wheel 96 Feb 14 2017 RemoteDesktopChangeClientSettings.pkg

/usr/local/sbin:
total 0
drwxr-xr-x 2 root wheel 64 Jun 25 09:09 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …

/usr/local/share:
total 0
drwxrwxr-x 38 dg admin 1216 Jun 24 17:00 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
[…]

/usr/local/var:
total 0
drwxr-xr-x 6 dg admin 192 Apr 4 2019 .
drwxr-xr-x 17 root wheel 544 Jun 25 09:09 …
drwxr-xr-x 3 dg admin 96 Nov 3 2015 cache
drwxr-xr-x 4 dg admin 128 Sep 18 2016 homebrew
drwxr-xr-x 3 dg admin 96 Oct 8 2016 log
drwxr-xr-x 2 dg admin 64 Oct 8 2016 mongodb

So brew link python requires write access to /usr/local/Frameworks, but:

/usr/local/Frameworks:
total 0
drwxr-xr-x 2 root wheel 64 Jun 25 09:09 .

it’s only writable by root. To address that:

$ sudo chown dg:admin /usr/local/Frameworks
$ brew link python
1 Like