Psutil: [macOS] Installation failure

Created on 29 Nov 2019  ·  5Comments  ·  Source: giampaolo/psutil

Platform

  • macOS Cataline 10.15.1
  • psutil==5.6.7

Bug description
pip install psutil==5.6.7 in a fresh Python 2.7.16 environment fails with over 5000 lines of /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:38: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness] alike errors

Traceback (partially)

...
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:329:30: note: insert '_Nonnull' if the pointer should never be null
    void     setprogname(const char *);
                                    ^
                                     _Nonnull
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:37: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:37: note: insert '_Nullable' if the pointer may be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                            ^
                                             _Nullable
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:37: note: insert '_Nonnull' if the pointer should never be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                            ^
                                             _Nonnull
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:38: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                             ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:38: note: insert '_Nullable' if the pointer may be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                             ^
                                               _Nullable
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:38: note: insert '_Nonnull' if the pointer should never be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                             ^
                                               _Nonnull
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:78: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                                                                     ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:78: note: insert '_Nullable' if the pointer may be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                                                                     ^
                                                                                       _Nullable
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:330:78: note: insert '_Nonnull' if the pointer should never be null
    int      sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
                                                                                     ^
                                                                                       _Nonnull
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:334:21: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
    void    *reallocf(void *__ptr, size_t __size) __alloc_size(2);
...
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:341:13: note: insert '_Nullable' if the pointer may be null
    extern char *suboptarg;         /* getsubopt(3) external variable */
                ^
                  _Nullable
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:341:13: note: insert '_Nonnull' if the pointer should never be null
    extern char *suboptarg;         /* getsubopt(3) external variable */
                ^
                  _Nonnull
    In file included from psutil/_psutil_osx.c:36:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:60:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:17:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:16:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1159:83: error: expected ','
        kCFURLBookmarkCreationWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0))  API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched
                                                                                      ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1160:98: error: expected ','
        kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 12 ), // Mac OS X 10.7.3 and later, if used with kCFURLBookmarkCreationWithSecurityScope, at resolution time only read access to the resource will be granted
                                                                                                     ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1170:85: error: expected ','
        kCFURLBookmarkResolutionWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 10 ), // Mac OS X 10.7.3 and later, use the secure information included at creation time to provide the ability to access the resource in a sandboxed process.
                                                                                        ^
    psutil/_psutil_osx.c:1837:15: warning: unused variable 'v' [-Wunused-variable]
        PyObject *v;
                  ^
    190 warnings and 3 errors generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /private/var/folders/wh/3lg8mt5s3p5d41gwndp7vts40000gn/T/tmp.eZcf4zI9/.venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wh/3lg8mt5s3p5d41gwndp7vts40000gn/T/pip-install-hTrgkc/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/wh/3lg8mt5s3p5d41gwndp7vts40000gn/T/pip-install-hTrgkc/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/wh/3lg8mt5s3p5d41gwndp7vts40000gn/T/pip-record-RuCpT9/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/wh/3lg8mt5s3p5d41gwndp7vts40000gn/T/tmp.eZcf4zI9/.venv/include/site/python2.7/psutil Check the logs for full command output.

Test results
As I'm unable to install the packages I've cloned the repository and checked out release-5.6.7 and ran python setup.py test which yielded a similar error like above, last lines being:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:339:36: note: insert '_Nonnull' if the pointer should never be null
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
                                            _Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:341:13: warning: pointer is missing a nullability type specifier
      (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:341:13: note: insert '_Nullable' if the pointer may be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:341:13: note: insert '_Nonnull' if the pointer should never be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nonnull
In file included from psutil/_psutil_osx.c:36:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:17:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:16:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1159:83: error: expected ','
    kCFURLBookmarkCreationWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0))  API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later...
                                                                                  ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1160:98: error: expected ','
    kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 12 ), // Mac OS X 10....
                                                                                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1170:85: error: expected ','
    kCFURLBookmarkResolutionWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 10 ), // Mac OS X 10.7.3 and later...
                                                                                    ^
psutil/_psutil_osx.c:1837:15: warning: unused variable 'v' [-Wunused-variable]
    PyObject *v;
              ^
bug macos

Most helpful comment

Hey I just encountered this... I followed the trail of bread crumbs and realized that I had two SDKs one for current and one past in /Library/Developer/CommandLineTools/SDKs/

so /Library/Developer/CommandLineTools/SDKs looked like:

MacOSX.sdk -> MacOSX10.15.sdk
MacOSX10.15.sdk
MacOSX10.14.sdk

I decided I didn't need MacOSX10.14.sdk so just ran sudo rm -rf /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/

After psutil installed I assume pointing to the 10.15.sdk

All 5 comments

Anyone come up with at least a temporary solution to fix it?

We're also hitting this - seems related to https://github.com/openid/AppAuth-iOS/issues/489

Hey I just encountered this... I followed the trail of bread crumbs and realized that I had two SDKs one for current and one past in /Library/Developer/CommandLineTools/SDKs/

so /Library/Developer/CommandLineTools/SDKs looked like:

MacOSX.sdk -> MacOSX10.15.sdk
MacOSX10.15.sdk
MacOSX10.14.sdk

I decided I didn't need MacOSX10.14.sdk so just ran sudo rm -rf /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/

After psutil installed I assume pointing to the 10.15.sdk

Workaround which works for me is to point MacOSX10.15.sdk to the previous SDK (MacOSX10.14.sdk) after which the package installs without any problems.

# Jump to the correct folder
cd /Library/Developer/CommandLineTools/SDKs

# Move the new SDK out of the way
sudo mv MacOSX10.15.sdk MacOSX10.15.sdk.1

# Link the newer SDK to the old one
sudo ln -s MacOSX10.14.sdk MacOSX10.15.sdk

# Install psutil or the package which depends on it
pip install -U psutil

# Remove the temporary symlink we made in step 3
sudo rm MacOSX10.15.sdk

# Restore to the former state
sudo mv MacOSX10.15.sdk.1 MacOSX10.15.sdk

I fixed this by recompiling python and linking it with latest sdk. This is easy with pyenv:

❯ pyenv uninstall 3.7.7
pyenv: remove /Users/rmax/.pyenv/versions/3.7.7? y

❯ pyenv install 3.7.7
WARNING: Please make sure you remove any previous custom paths from your /Users/rmax/.pydistutils.cfg file.
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.7.tar.xz...
-> https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
Installing Python-3.7.7...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.7.7 to /Users/rmax/.pyenv/versions/3.7.7

❯ pyenv local 3.7.7

❯ python-config --cflags
-I/Users/rmax/.pyenv/versions/3.7.7/include/python3.7m -I/Users/rmax/.pyenv/versions/3.7.7/include/python3.7m -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   

My previous python was linked to 10.14 sdk:

❯ python-config --cflags
-I/Users/rmax/.pyenv/versions/3.7.7/include/python3.7m -I/Users/rmax/.pyenv/versions/3.7.7/include/python3.7m -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include  

Was this page helpful?
0 / 5 - 0 ratings