我需要将一些需要安装的包导入到python中。从命令行(zsh)我尝试使用 pip、python 和 homebrew(我使用的是 Mac OS Big Sur),但在需要 pyobjc 时出现错误:“ValueError: int() 基数为 10 的文字无效: '''。这与我尝试安装 pyobjc 时遇到的错误相同(我尝试过 pip、brew 并下载源代码并运行 setup.py)。我尝试过使用 pip 和 python 2.7 和 3.9 版本。我该如何调试这个?我看到错误的结尾:
File "/usr/local/Cellar/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="33434a475b5c5d73001d0a" rel="noreferrer noopener nofollow">[email protected]</a>/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.
我也在运行 Big Sur,当我运行 /usr/bin/xcrun -sdk macosx --show-sdk-path
时,我返回 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
。安装系统删除了“MacOSX”和“.sdk”以检查版本,然后将空字符串转换为整数似乎是崩溃的原因。
我还查看了 PyObjC 存储库中的现有问题,瞧,这是最近的一个问题:https://github.com/ronaldoussoren/pyobjc/issues/333 。根据developer's comment ,这个问题应该在即将发布的 PyObjC 版本 7 中得到修复。
关于python - 如何修复 "ValueError: invalid literal for int() with base 10: ' ' 的发生。每当需要 pyobjc 时,包括安装 pyobjc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64998776/