【问题标题】:Big Sur clang "invalid version" error due to MACOSX_DEPLOYMENT_TARGET由于 MACOSX_DEPLOYMENT_TARGET,Big Sur clang “无效版本”错误
【发布时间】:2021-01-06 08:36:24
【问题描述】:

我认为由于 Big Sur 正在为新操作系统推出新的修补程序这一事实尚未发生。尝试安装使用clang进行编译的模块时,会抛出以下错误:

clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0'

目前正在运行:

  • Mac OS Big Sur,11.0 测试版
  • 英特尔 CPU (i386)
  • Python 3.8.0 通过pyenv 安装

多个模块具有clang 依赖关系,因此这个错误似乎很常见。一个例子:

pip install multidict

安装旧版本的命令行工具(例如 11.5)也不起作用。

【问题讨论】:

    标签: python macos


    【解决方案1】:

    我想扩展@Felipe 出色的答案; 如果即使运行也不行

    >>> softwareupdate --all --install --force
    Software Update Tool
    
    Finding available software
    No updates are available.
    

    ...按照“自制医生”的智慧解决它,即删除并重新安装:

    sudo rm -rf /Library/Developer/CommandLineTools
    sudo xcode-select --install
    

    【讨论】:

    • 很棒的发现。感谢您提醒我更新我的答案 - 从那时起,Apple 现在要求用户从他们的网站安装最新版本的 Xcode 命令行工具。为其他正在寻找答案的人更新。
    • 答案的第二部分为我修复了它。
    • 第二部分对我有用,但后来我不得不重新切换 xcode-select sudo xcode-select --switch /Library/Developer/CommandLineTools
    【解决方案2】:

    找出我的问题。

    之前我从 App Store (11.7) 安装了 XCode 并将其 SDK 设置为我的默认值:

    sudo xcode-select --switch /Applications/Xcode.app/
    

    但是,它似乎带有不受支持的 clang 版本:

      λ clang --version
    Apple clang version 11.0.3 (clang-1103.0.32.62)
    Target: x86_64-apple-darwin20.1.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    

    通过以下方式将xcode-select 设置为最新版本:

    sudo xcode-select --switch /Library/Developer/CommandLineTools
    

    编辑(2020 年 11 月 15 日)

    尝试上述更改时,您可能会收到错误消息:

    xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'

    要解决此问题,您必须从 Apple 官方网站 here 安装最新的命令行工具。在编写此编辑时,我安装了 Xcode 12.3 beta 的命令行工具

    clang 更改为工作版本:

      λ clang --version
    Apple clang version 12.0.0 (clang-1200.0.32.2)
    Target: x86_64-apple-darwin20.1.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

    内置的 Big Sur SDK 版本为10.15,似乎可以正常工作:

      λ ls /Library/Developer/CommandLineTools/SDKs
    MacOSX.sdk      MacOSX10.15.sdk
    

    切换后multidict安装成功。

      λ pip install multidict
    Collecting multidict
      Downloading multidict-4.7.6-cp38-cp38-macosx_10_14_x86_64.whl (48 kB)
         |████████████████████████████████| 48 kB 589 kB/s
    Installing collected packages: multidict
    Successfully installed multidict-4.7.6
    

    进一步调查似乎表明这是 Apple (source) 的设计选择:

    因此,确保您的 SDK 是开箱即用的默认 SDK,而不是 XCode 的新 SDK,应该足以让系统在需要时切换上下文(并且似乎可以与 pip+clang 配合使用) .

    【讨论】:

      【解决方案3】:

      在我的情况下,我必须删除 /Library/Developer/CommandLineTools 并重新安装命令行工具

      % sudo rm -rf /Library/Developer/CommandLineTools
      % sudo xcode-select --install
      % clang --version
      Apple clang version 12.0.0 (clang-1200.0.32.27)
      Target: x86_64-apple-darwin20.1.0
      Thread model: posix
      InstalledDir: /Library/Developer/CommandLineTools/usr/bin
      

      【讨论】:

      • 谢谢!我有 clang 11.0.3,但 macOS“软件更新”没有更新它。删除并重新安装工作。
      • 上帝保佑你!!!
      【解决方案4】:

      我已经删除并重新安装了 xtools CLI,但错误仍然存​​在..

      我需要做的就是

      export SYSTEM_VERSION_COMPAT=1
      

      然后错误消失了

      【讨论】:

      • 我使用的是pipenv install,然后它在控制台中吐出大量错误和警告,然后设置它后,它就像魅力一样工作,所有依赖项都顺利安装/解决。这拯救了我的一天!谢谢
      【解决方案5】:

      在我的例子中,删除 CLT 和 LLVM 并设置刚刚编译的 XCode。

      % sudo rm -rf /Library/Developer/CommandLineTools
      % sudo xcode-select --switch /Applications/Xcode.app
      % brew uninstall llvm # if installed via brew
      % clang --version
      Apple clang version 12.0.0 (clang-1200.0.32.28)
      Target: x86_64-apple-darwin20.2.0
      Thread model: posix
      InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
      

      gcc 和 g++ 现在编译没有任何错误。

      【讨论】:

        猜你喜欢
        • 2021-03-05
        • 2022-11-09
        • 2021-04-18
        • 2021-11-30
        • 2021-12-04
        • 1970-01-01
        • 2021-06-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多