How to fix "ValueError: invalid literal for int() with base 10: '' occuring. whenever pyobjc is needed including installing pyobjc

How to fix "ValueError: invalid literal for int() with base 10: '' occuring. whenever pyobjc is needed including installing pyobjc

我需要将一些需要安装的软件包导入 python。从命令行 (zsh) 我尝试使用 pip、python 和自制软件(我正在使用 Mac OS Big Sur)但是在需要 pyobjc 时出现错误:“ ValueError:以 10 为底的 int() 的无效文字:''"。这与我在尝试安装 pyobjc 时遇到的错误相同(我尝试过 pip、brew 和下载源代码以及 运行 setup.py)。我试过使用 2.7 和 3.9 版的 pip 和 python。我该如何调试呢?我看到错误的结尾:

  File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/var/folders/hf/7khqn6yn0nz3mny8210jr0380000gn/T/pip-install-ropcjbe2/pyobjc-core/setup.py", line 619, in run
    % (tuple(map(int, get_sdk_level(self.sdk_root).split("."))))
ValueError: invalid literal for int() with base 10: ''

我不确定要查看哪个文件才能确定问题出在哪里

经过一些研究,我发现了一些线索可以阐明这个主题。

this论坛中,有解释安装时出现错误的原因。

...the data it's parsing here is the output of /usr/bin/xcrun -sdk macosx --show-sdk-path. That should return the full SDK path on Xcode 5 and later...

It should return something like /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk. The parsing code takes the last path component (MacOSX10.14.sdk), strips off the first 6 characters (MacOSX) and the last 4 characters (.sdk), which should leave just the version number (10.14), which is split on . and the two parts are cast as integers. In your case, this seems to be empty.

我也是运行宁大苏尔,等我运行/usr/bin/xcrun -sdk macosx --show-sdk-path回来/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk。安装系统删除了 'MacOSX' 和 '.sdk' 以检查版本,然后将空字符串转换为整数似乎是崩溃的原因。

我还查看了 PyObjC 存储库中存在的问题,瞧,这是一个最近的问题:https://github.com/ronaldoussoren/pyobjc/issues/333. As per the developer's comment,即将发布的 PyObjC 版本 7 应该会解决这个问题。