xuzhengfu / pilot

进入编程世界的第一课
1 stars 0 forks source link

brew install python 报错 #13

Open xuzhengfu opened 4 years ago

xuzhengfu commented 4 years ago

感谢老师!

0. 基本信息

执行 which brew python git conda,结果如下:

xuzhengfu at xuzhengfudeiMac in ~ $ which brew /usr/local/bin/brew (base)

xuzhengfu at xuzhengfudeiMac in ~ $ which python /Users/xuzhengfu/anaconda3/bin/python (base)

xuzhengfu at xuzhengfudeiMac in ~ $ which python3 /Users/xuzhengfu/anaconda3/bin/python3 (base)

xuzhengfu at xuzhengfudeiMac in ~ $ which git /usr/local/bin/git (base)

xuzhengfu at xuzhengfudeiMac in ~ $ which conda /Users/xuzhengfu/anaconda3/bin/conda (base)

1. 执行 brew install python

结果如下:

Updating Homebrew...

==> Installing dependencies for python: gdbm, openssl@1.1, readline, sqlite and xz

==> Installing python dependency: gdbm

==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.mojave.bottle.

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

==> Pouring gdbm-1.18.1.mojave.bottle.1.tar.gz

🍺 /usr/local/Cellar/gdbm/1.18.1: 20 files, 586.8KB

==> Installing python dependency: openssl@1.1

==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1d.mojave.

==> Downloading from https://akamai.bintray.com/10/104ef018b7bb8fcc49f57e5a6035

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

==> Pouring openssl@1.1-1.1.1d.mojave.bottle.tar.gz

==> Caveats

A CA file has been bootstrapped using certificates from the system

keychain. To add additional certificates, place .pem files in

/usr/local/etc/openssl@1.1/certs

and run

/usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,

because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:

echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"

export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary

🍺 /usr/local/Cellar/openssl@1.1/1.1.1d: 7,983 files, 17.9MB

==> Installing python dependency: readline

==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.1.mojave.bott

==> Downloading from https://akamai.bintray.com/3c/3c754391e9d243835811d128771c

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

==> Pouring readline-8.0.1.mojave.bottle.tar.gz

==> Caveats

readline is keg-only, which means it was not symlinked into /usr/local,

because macOS provides the BSD libedit library, which shadows libreadline.

In order to prevent conflicts when programs look for libreadline we are

defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:

export LDFLAGS="-L/usr/local/opt/readline/lib"

export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

==> Summary

🍺 /usr/local/Cellar/readline/8.0.1: 48 files, 1.5MB

==> Installing python dependency: sqlite

==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.30.1.mojave.bottl

==> Downloading from https://akamai.bintray.com/5e/5e6fef2d754e0e4009d502c40ad1

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

==> Pouring sqlite-3.30.1.mojave.bottle.tar.gz

==> Caveats

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:

echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find sqlite you may need to set:

export LDFLAGS="-L/usr/local/opt/sqlite/lib"

export CPPFLAGS="-I/usr/local/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> Summary

🍺 /usr/local/Cellar/sqlite/3.30.1: 11 files, 3.9MB

==> Installing python dependency: xz

==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.mojave.bottle.tar

==> Downloading from https://akamai.bintray.com/01/010667293df282c8bceede3bcd36

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

==> Pouring xz-5.2.4.mojave.bottle.tar.gz

🍺 /usr/local/Cellar/xz/5.2.4: 92 files, 1MB

==> Installing python

==> Downloading https://homebrew.bintray.com/bottles/python-3.7.6_1.mojave.bott

==> Downloading from https://akamai.bintray.com/64/643d627c2b4fc03a3286c397d299

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

==> Pouring python-3.7.6_1.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

(base)

2. 再次执行 brew install python

结果如下:

Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae cmt helib keydb psc-package ==> Updated Formulae b3sum csound gifski insect lighttpd rust binutils gatsby-cli gitleaks joplin mockserver sqlmap cake get_iplayer gitmoji libtensorflow@1 rclone xcodegen

Warning: python 3.7.6_1 is already installed, it's just not linked You can use brew link python to link this version. (base)

3. 执行 brew link python

结果如下:

Linking /usr/local/Cellar/python/3.7.6_1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks (base)

xuzhengfu commented 4 years ago

老师回复:

你这个问题的内容和排版读起来可真是吃力啊(不信你可以自己从头读一遍)。建议你看看其他 issue,以及讲 Markdown 的支线课程。

回到你的具体问题。首先,你之前装过 Anaconda,这个东西很麻烦,我是非常不推荐的——当然,很多年前 Python 一些基础设施不完备,Anaconda 还是做了不少有益工作的,现在基本不需要了,只剩下它的麻烦了。

你目前 python python3 都是指向 Anaconda 安装的版本,如果你要用 Homebrew,就要先把 Anaconda 删掉,或者在你的 .bash_profile 或者 .zshrc 里调整 PATH 变量,把 Anaconda 目录从其中移除。

第二, 你执行 python -V 命令肯定是打错了,实际上执行了 python -v。我一直说学编程不难,只有两个前提:1. 做事认真仔细;2. 努力和计算机做朋友。你敲的每个命令就是在和计算机聊天,你和人聊天不可能不去搞明白自己说了啥,对方说了啥吧?

最后,你的 /usr/local/Frameworks 这个目录的权限不对,不知道你的环境之前做过什么,所以不清楚原因是什么,但这导致 Homebrew 没法正常的安装软件,你可以试试修正这个问题,比如:

sudo chown -R xuzhengfu /usr/local/Frameworks

然后再重新用 Homebrew 安装 python,或者直接 brew link python

xuzhengfu commented 4 years ago

我回复:

感谢李骏老师!我根据您的指示试着处理以下问题(并以链接形式附上了详尽的工作记录):

  1. 卸载 anaconda
  2. “/usr/local/Frameworks 目录的权限不对” 的处理

在使用 brew 安装 python 和 git 的过程中,还出现了「一些」警告信息,「某个」如下:

==> Caveats
gettext is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD gettext library & some software gets confused if both are in the library path.

If you need to have gettext first in your PATH run:
  echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

For compilers to find gettext you may need to set:
  export LDFLAGS="-L/usr/local/opt/gettext/lib"
  export CPPFLAGS="-I/usr/local/opt/gettext/include"

这种情况需要处理吗?

另,关于老师指出的「issues 书写问题」,我一定悉心学习。关于此回复的不当之处,恳请老师予以指正。感谢李骏老师!

xuzhengfu commented 4 years ago

老师回复:

上面的这个不是警告,是一些说明信息,对我们目前学习来说,可以无视。

后面这个排版就好多了 😀