[英]The "Python" command requires the command line developer tools loop with Xcode 13.4.1 on macOS 12.5
My setup is 2021 MBP with M1 Pro processor, macOS 12.5 and Xcode 13.4.1.我的设置是 2021 MBP,带有 M1 Pro 处理器、macOS 12.5 和 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."我正在使用 NativeScript 构建一个应用程序,但我无法发布该应用程序,因为每次我 go 到product
> archive
Xcode 都说“Python 命令需要命令行工具”。 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.我重置了我的 Mac 并重新安装了 macOS,因此使用了全新的设置。 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.首先,我遵循 NativeScript 文档的建议( https://docs.nativescript.org/environment-setup.html#macos-ios (创建)并运行sudo ln -s $(which python3) /usr/local/bin/python
python 2.x 的别名。 Then did python3 -m pip install --upgrade pip
and python3 -m pip install six
.然后python3 -m pip install --upgrade pip
和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.用ns doctor ios
测试了我的配置 - 它抱怨缺少 python 和 Xcode 对话框提示我安装 Z23EEEB4347BDD756BDDFC6。 Click install, it finishes, running ns doctor ios
and starting over.点击安装,完成,运行ns doctor ios
并重新开始。
While it seems like macOS 12.5 ships with python3 already none of the options worked me.虽然看起来 macOS 12.5 附带了 python3,但没有一个选项对我有用。
Later found an article where the author suggested installing python using pyenv
.后来发现一篇文章,作者建议使用pyenv
。 So I went that path, installed it globally and set env into my shell.所以我走那条路,全局安装它并将 env 设置到我的 shell 中。 Retested and got the same error.重新测试并得到相同的错误。
Xcode-select -p
results in /Applications/Xcode.app/Contents/Developer
Xcode-select -p
导致/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.我注意到 Xcode 的文件夹中有 python3.8 但这也不起作用。 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.我有点困惑为什么 Xcode 现在在它自己的文件夹中寻找 Xcode 并且不使用 macOS 附带的 python3。
I finally found a fix.我终于找到了解决办法。
Steps I did to make it work:我为使其工作而采取的步骤:
pyenv
using pyenv uninstall 3.10.6
删除了使用pyenv uninstall 3.10.6
通过pyenv
安装的 pythonbrew uninstall pyenv
to remove pyenv
Ran brew uninstall pyenv
删除pyenv
brew install python
python --version
results in Python 3.9.13
python --version
结果为Python 3.9.13
sudo ln -s $(which python3) /usr/local/bin/python
最后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.所以基本上如果你在一个新系统上执行第 4 步和第 6 步,你应该对 go 很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.