iTerm2 can be scripted with Python
When I run Python REPL or Python script through iTerm2 Scripting menu on Apple Sillicon architecture (M2 in my case) it terminates with following error:
Bad CPU type
like in this example stacktrace:
2-3, 2:43:17.371 PM: /opt/homebrew/bin/zsh -c /Applications/iTerm.app/Contents/Resources/it2_api_wrapper.sh /Users/zxaos/.config/iterm2/AppSupport/iterm2env-3.7/versions/3.7.9/bin/python3 /Users/zxaos/.config/iterm2/AppSupport/Scripts/AutoLaunch/iTerm-DarkLight.py 12-3, 2:43:17.381 PM: + unset PYTHONPATH 12-3, 2:43:17.381 PM: + export PYTHONUNBUFFERED=1 12-3, 2:43:17.381 PM: + PYTHONUNBUFFERED=1 12-3, 2:43:17.381 PM: + /Users/zxaos/.config/iterm2/AppSupport/iterm2env-3.7/versions/3.7.9/bin/python3 /Users/zxaos/.config/iterm2/AppSupport/Scripts/AutoLaunch/iTerm-DarkLight.py 12-3, 2:43:17.381 PM: /Applications/iTerm.app/Contents/Resources/it2_api_wrapper.sh: line 6: /Users/zxaos/.config/iterm2/AppSupport/iterm2env-3.7/versions/3.7.9/bin/python3: Bad CPU type in executable 12-3, 2:43:17.382 PM: 12-3, 2:43:17.382 PM: ** Script exited with status 126 **
How to solve it?