My setup is 2021 MBP with M1 Pro processor, macOS 12.5 and Xcode 13.4.1. I'm building an app using NativeScript and I can't release the app because every time I go to product
> archive
Xcode says "Python command requires the command line tools." When I agree to install it will look like it installed but then start over.
I reset my Mac and reinstalled macOS so a fresh setup was used. First I followed the suggestion from NativeScript docs (https://docs.nativescript.org/environment-setup.html#macos-ios) and ran sudo ln -s $(which python3) /usr/local/bin/python
which created an alias for python 2.x. Then did python3 -m pip install --upgrade pip
and python3 -m pip install six
. Tested my configuration with ns doctor ios
- it complained about missing python and Xcode dialog prompted me to install python. Click install, it finishes, running ns doctor ios
and starting over.
While it seems like macOS 12.5 ships with python3 already none of the options worked me.
Later found an article where the author suggested installing python using pyenv
. So I went that path, installed it globally and set env into my shell. Retested and got the same error.
Xcode-select -p
results in /Applications/Xcode.app/Contents/Developer
I tried:
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Applications/Xcode.app/Contents/Developer/usr/bin/python
and
sudo ln -s /Library/Developer/CommandLineTools/usr/bin/python3 /Library/Developer/CommandLineTools/usr/bin/python
None helped. I also tried
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3.8 /Applications/Xcode.app/Contents/Developer/usr/bin/python
as I noticed there's python3.8 in Xcode's folder but that didn't work either. I'm a bit confused why Xcode is looking for Xcode in it's own folder now and doesn't use python3 that comes with macOS.
I finally found a fix.
Steps I did to make it work:
pyenv
using pyenv uninstall 3.10.6
brew uninstall pyenv
to removepyenv
brew install python
python --version
results in Python 3.9.13
sudo ln -s $(which python3) /usr/local/bin/python
So essentially if you're on a new system do steps 4 and 6 and you should be good to go.