pythonpippyobjcmacos-big-sur

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


I need to import a number of packages into python that require installation. From the command line (zsh) I've attempted to use pip, python and homebrew(I'm using Mac OS Big Sur) but get an error when pyobjc is required: "ValueError: invalid literal for int() with base 10: ''". This is the same error I get when trying to install pyobjc (I've tried pip, brew and downloading the source and running setup.py). I've tried using version 2.7 and 3.9 of pip and python. How can I go about debugging this? I see the end of the error:

  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: ''

I'm not sure what file to look at to see where this problem is


Solution

  • After doing some research, I've found a few threads that shed some light on this subject.

    In this forum, there is an explanation of why the error occurs at install.

    ...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.

    I am also running Big Sur, and when I run /usr/bin/xcrun -sdk macosx --show-sdk-path, I get back /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk. The install system removes both 'MacOSX' and '.sdk' to check the version, and then casting the empty string to an integer seems to be the cause of the crash.

    I also looked at the PyObjC repository for existing issues, and voila, here is a very recent one: https://github.com/ronaldoussoren/pyobjc/issues/333. As per the developer's comment, this should be fixed with the upcoming release of version 7 of PyObjC.