Homebrewでpython3を入れようとした
$ brew install python3
(中略)
==> /usr/local/Cellar/python@3.9/3.9.7_1/bin/python3 -m ensurepip
Last 15 lines from /Users/*/Library/Logs/Homebrew/python@3.9/post_install.01.python3:
(中略)
subprocess.CalledProcessError: Command '['/usr/local/opt/python@3.9/bin/python3.9', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/private/tmp/tmp7r1s7_i7/setuptools-57.4.0-py3-none-any.whl\', \'/private/tmp/tmp7r1s7_i7/pip-21.2.4-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/private/tmp/tmp7r1s7_i7\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
Warning: The post-install step did not complete successfully
You can try again using:
brew postinstall python@3.9
python自体は使えるが、正常に完了しない
そして、pipを使おうとすると
$ pip3 -V
pip 19.0.3 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
思ってたのと違う……
#結論
https://pip.pypa.io/en/stable/installation/
ここに書いてあった
$ python3 -m ensurepip
これで~/Library/Python/3.9/bin
にpipがインストールされる
再度pythonインストール
$ brew reinstall python3
こんどは正常にインストール完了し、/usr/local/bin/
にもシンボリックリンクが作成される
(再インストールしないでも普通に$ brew postinstall python@3.9
でよかったかもしれない)
$ pip3 -V
pip 21.2.4 from /Users/*/Library/Python/3.9/lib/python/site-packages/pip (python 3.9)
pipのアップデートもしておきましょう
$ pip3 install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./Library/Python/3.9/lib/python/site-packages (21.2.4)
Collecting pip
Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.4
Uninstalling pip-21.2.4:
Successfully uninstalled pip-21.2.4
Successfully installed pip-21.3.1
参考になったが今回の解決法とは違っていた情報たち
https://ja.stackoverflow.com/questions/44308/homebrewでpython3をインストールするとpipが使えない
https://stackoverflow.com/questions/47255517/brew-install-python3-didnt-install-pip3