brewでバージョンを下げる
https://zenn.dev/naan4810/articles/bcd16b0fff165c 多分これと同じ状況になったので、pythonを3.12系から3.11以前の物に一時的に下げたかった。
update-alternatives みたいな仕組みがなんかある? と予想したけどよくわかっていない。
brew switch がそれっぽい予感はするものの、既になくなったサブコマンドらしい。sh% brew unlink pythonUnlinking /opt/homebrew/Cellar/python@3.12/3.12.3... 25 symlinks removed.% brew link python@3.11Warning: Already linked: /opt/homebrew/Cellar/python@3.11/3.11.9To relink, run: brew unlink python@3.11 && brew link python@3.11% python3 -VPython 3.9.6なんかよくわからないけど3.9.6まで下がった。
とりあえず
gcloud components update ができたからこのバージョンでもいいか……。無事
gcloud components update が終わったら、今度は3.12に帰りたい。sh% brew link pythonLinking /opt/homebrew/Cellar/python@3.12/3.12.3... 25 symlinks created.% python3 -VPython 3.12.3なんか戻った気がする。
brew link python@3.11 は3.11そのものへのlinkを作るものっぽい……? じゃあなんでunlink pythonしたら3.9が出たんだろう?
よくわからないけど、今回は望むことは達成できたからこれでいいか……。
なんで突然3.9が出たかは、systemのものが出たんでは? となった。
sh% brew unlink pythonUnlinking /opt/homebrew/Cellar/python@3.12/3.12.3... 25 symlinks removed.% which python3/usr/bin/python3% python3 -V Python 3.9.6 brew link python@3.11 が作る何かというのは、 python3.11 コマンドぽい感じがする。sh % python3.11 -VPython 3.11.9% brew unlink python@3.11 Unlinking /opt/homebrew/Cellar/python@3.11/3.11.9... 11 symlinks removed.% python3.11 -V zsh: command not found: python3.11ためしにunlinkすると消滅する。
なんかうまいコマンドを叩くと、
python3 -V で3.11系が出るようになりそうだが……? 実はそういうことはできないっぽい?
/opt/homebrew/opt/python@3.11/libexec/bin/python3 とかはあるので、 PATH の先頭に /opt/homebrew/opt/python@3.11/libexec/bin をつっこんでやると、それっぽく動作するのか……? しかし、例えば
PATH=/opt/homebrew/opt/python@3.11/libexec/bin:$PATH gcloud components update などを叩いて、実は他の環境変数とかも変えてあげる必要があったりして混ざって終了 みたいな出来事が発生しないのか……? という不安が少しあるような……。 それで困らない範囲なら、単に
brew unlink python でsystemの3.9に戻って実行する などしたほうが安全では……? という予感もする……?`
#python #homebrew