環境
- macOS Big Sur version 11.3.1
- Terminal (Bash)
- Python 3.12.4
macOS terminalでaptコマンドをあれこれupdateしたりして、python実行時に以下のエラーが出た
1 2 3 |
xcrun: error: active developer path ("/Library/Developer/CommandLineTools") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools. See `man xcode-select` for more details. |
どうやらxcode
が見つからないらしい。
自分の場合、macOSではxcode
に同梱されているpythonを利用しているのだが、エラー文によるとどうやらxcode
へのパスを指定するか、再インストールするかしてくださいとのこと。
今回のケースだと、xcode
はインストールされていたので、パスを再設定しようと思う。インストールする場合は以下のコマンドを実施するべし(インストールは結構時間掛かった気がする)
1 |
xcode-select --install |
とりあえず、xcode
のパスを調べてみたら、本来は/Applications
にあるところが、自分はなぜかダウンロードディレクトリに置きっぱなしだったので、一旦/Applications
に移動して、以下コマンドでパスを指定
1 |
sudo xcode-select --switch /Applications/Xcode-beta.app |
xcode
がbetaじゃない場合はアプリの名前はこっちかも
1 |
sudo xcode-select --switch /Applications/Xcode.app |
無事python動きました
1 2 3 4 5 |
$ python3 Python 3.8.2 (default, Feb 25 2021, 09:38:33) [Clang 12.0.5 (clang-1205.0.22.6)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> |