macOS 12.3 で Python2 が消え、スクリプトが「bad interpreter: /usr/bin/python: no such file or directory」とは。

便利スクリプトツールたちが使えなくなってつらし。


#!/usr/bin/python -u
...

macOS 12.3 で /usr/bin/python は削除され、 /usr/bin/python3 しかないのですが。という件。

👉 `pidcat` installed via `brew` no longer works on macOS 12.3, due to Python 2 having been removed · Issue #180 · JakeWharton/pidcat hatena-bookmark

python 2 をインストールして、そのパスに1行目を書き換える。


#!/usr/bin/env -S python -u


#!/Users/<user>/.pyenv/versions/2.7.18/bin/python -u


#!/usr/local/Cellar/python@2/2.7.15_1/bin/python2 -u

macOS SIP により python から python3ln -s で向けることはできない。

👉 Mac のシステム整合性保護について - Apple サポート (日本) hatena-bookmark

まとめ

pidcat に関しては以下で。


❯ pyenv global 2.7.18

❯ pyenv versions
  system
* 2.7.18 (set by /Users/username/.pyenv/version)
  3.10.4


#!/usr/bin/env -S python -u
...

bad interpreter: /usr/bin/python: no such file or directory

しかし、pyenv て便利なやつだなあ。

👉 pyenv/pyenv: Simple Python version management hatena-bookmark

👉 【Python】「pip search」の代わりは何なの? hatena-bookmark