简体   繁体   English

“Python”命令需要在 macOS 12.5 上使用 Xcode 13.4.1 的命令行开发人员工具循环

[英]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 pippython3 -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:我为使其工作而采取的步骤:

  1. Removed all symlinks I've set originally删除了我最初设置的所有符号链接
  2. Removed python installed via pyenv using pyenv uninstall 3.10.6删除了使用pyenv uninstall 3.10.6通过pyenv安装的 python
  3. Ran brew uninstall pyenv to remove pyenv Ran brew uninstall pyenv删除pyenv
  4. brew install python
  5. python --version results in Python 3.9.13 python --version结果为Python 3.9.13
  6. And finally 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.

相关问题 git(或python)命令需要命令行开发者工具 - The git (or python) command requires the command line developer tools “git”命令需要命令行开发工具。 您要安装吗? - The "git" command requires the command line developer tools. Would you like to install? macOS 大苏尔; 命令行工具和 Python 3.8.2 - macOS Big Sur; Command Line Tools and Python 3.8.2 如何通过苹果 xcode 命令行工具 (3.8.9) 将 /usr/bin/python3 中的 python 更新到最新版本 - How to update python at /usr/bin/python3 to the latest available via apple xcode command line tools(3.8.9) Python脚本需要在命令行中输入 - Python script requires input in command line 从NodeJS执行python命令行工具 - Executing python command line tools from NodeJS Python,并行运行命令行工具 - Python, running command line tools in parallel 如何测试需要命令行参数的 Python class? - how to test a Python class that requires command line argument? 如何在导入前导入需要命令行 arguments 的 python 脚本? - How import python script that requires command line arguments before importing? 如何从需要命令行输入的python脚本中导入 - How to import from a python script that requires command line input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM