My開発メモ

Python3はmacのどこにインストールされたのか?

Python3 のインストールは以下のコマンドでできる。

% brew install python3

さて、どこにインストールされたか?

homebrew でインストールしたあとのメッセージによると、

/opt/homebrew/bin/python3

にインストールされている。

% which python3
/opt/homebrew/bin/python3

たしかに。

しかし、以下のようにすると…

% ls -l /opt/homebrew/bin | grep python
python3@ -> ../Cellar/python@3.11/3.11.3/bin/python3
python3.11@ -> ../Cellar/python@3.11/3.11.3/bin/python3.11

となっている。

それなら、以下を実行すると…

% ls -l /opt/homebrew/Cellar/pyton#3.11/3.11.3/bin | grep python3
python3@ -> ../Frameworks/Python.framework/Versions/3.11/bin/python3
python3.11@ -> ../Frameworks/Python.framework/Versions/3.11/bin/python3.11

となっている。

ということで、以下を実行してみたら…

% ls -l
/opt/homebrew/Cellar/pyton#3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin
python3@ -> python3.11
python3.11*

やっとめぐり会えました。

ここには、idle3.11、pip3、pip3.11 もいらっしゃいました。

idleも同じく、ここの idle3.11 にリンクが貼られている。

% which idle
/opt/homebrew/opt/python@3.11/libexec/bin/idle
% which idle3
/opt/homebrew/bin/idle3

と、それぞれ表示されるが、いずれもリンクであって、本体は、

/opt/homebrew/Cellar/pyton#3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/idle3.11

である。

では pip は?

% ls -l $(which pip)
/opt/homebrew/opt/python@3.11/libexec/bin/pip@ -> ../bin/pip3.11
% ls -l $(which pip3)
/opt/homebrew/bin/pip3@ -> ../Cellar/python@3.11/3.11.3/bin/pip3
% ls -l /opt/homebrew/opt/python@3.11/bin | grep pip
pip3*
pip3.11*
% ls -l /opt/homebrew/Cellar/python@3.11/3.11.3/bin | grep pip
pip3*
pip3.11*

一見すると別々のディレクトリのようだが、

% ls -l /opt/homebrew/opt/python@3.11@ -> ../Cellar/python@3.11/3.11.3

なので、結局は同じなのであった。

結論

python
python3
python3.11
/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/python3.11
idle
idle3
idle3.11
/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/idle3.11
pip
/opt/homebrew/Cellar/python@3.11/3.11.3/bin/pip3
pip3
/opt/homebrew/Cellar/python@3.11/3.11.3/bin/pip3.11

と、pipだけが他と違う。
/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/
にも、pipとpip3.11がインストールされているので、なぜこうなったのか?

ちなみに、pip3 pip3.11 のタイムスタンプは同じである。
同時に2箇所にインストールしたってことか?

カテゴリー: MacOS, memo, Python, Python3

タグ: install, mac, Python3, where, どこ

カウント: 190