Psutil: [macOS Mojave 10.14.4] Fails to build

Created on 25 Apr 2019  ·  3Comments  ·  Source: giampaolo/psutil

Platform
macOS Mojave 10.14.4

$ sudo xcode-select --reset
$ pip3 install psutil
Collecting psutil
  Using cached https://files.pythonhosted.org/packages/2f/b8/11ec5006d2ec2998cb68349b8d1317c24c284cf918ecd6729739388e4c56/psutil-5.6.1.tar.gz
Building wheels for collected packages: psutil
  Building wheel for psutil (setup.py) ... error
  Complete output from command /usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-install-ftebqf7v/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-wheel-himmqv1f --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-x86_64-3.7
  creating build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_pswindows.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_common.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_psosx.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_psbsd.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_psaix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_pslinux.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_compat.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_psposix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  copying psutil/_pssunos.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
  creating build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_aix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
  running build_ext
  building 'psutil._psutil_osx' extension
  creating build/temp.macosx-10.14-x86_64-3.7
  creating build/temp.macosx-10.14-x86_64-3.7/psutil
  creating build/temp.macosx-10.14-x86_64-3.7/psutil/arch
  creating build/temp.macosx-10.14-x86_64-3.7/psutil/arch/osx
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_common.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_common.o
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_posix.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_posix.o
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_osx.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_osx.o
  In file included from psutil/_psutil_osx.c:36:
  In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:
  In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
  /usr/local/include/Block.h:16:3: error: Never include this file directly. Use <lzma.h> instead.
  #       error Never include this file directly. Use <lzma.h> instead.
          ^
  /usr/local/include/Block.h:93:2: error: unknown type name 'lzma_check'
          lzma_check check;
          ^
  /usr/local/include/Block.h:148:2: error: unknown type name 'lzma_vli'
          lzma_vli compressed_size;
          ^
  /usr/local/include/Block.h:172:2: error: unknown type name 'lzma_vli'
          lzma_vli uncompressed_size;
          ^
  /usr/local/include/Block.h:200:2: error: unknown type name 'lzma_filter'
          lzma_filter *filters;
          ^
  /usr/local/include/Block.h:217:20: error: use of undeclared identifier 'LZMA_CHECK_SIZE_MAX'
          uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
                            ^
  /usr/local/include/Block.h:231:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int3;
          ^
  /usr/local/include/Block.h:232:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int4;
          ^
  /usr/local/include/Block.h:233:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int5;
          ^
  /usr/local/include/Block.h:234:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int6;
          ^
  /usr/local/include/Block.h:235:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int7;
          ^
  /usr/local/include/Block.h:236:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int8;
          ^
  /usr/local/include/Block.h:237:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum1;
          ^
  /usr/local/include/Block.h:238:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum2;
          ^
  /usr/local/include/Block.h:239:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum3;
          ^
  /usr/local/include/Block.h:240:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum4;
          ^
  /usr/local/include/Block.h:261:2: error: unknown type name 'lzma_bool'
          lzma_bool ignore_check;
          ^
  /usr/local/include/Block.h:263:2: error: unknown type name 'lzma_bool'
          lzma_bool reserved_bool2;
          ^
  /usr/local/include/Block.h:264:2: error: unknown type name 'lzma_bool'
          lzma_bool reserved_bool3;
          ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  error: command 'clang' failed with exit status 1

  ----------------------------------------
  Failed building wheel for psutil
  Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil
  Running setup.py install for psutil ... error
    Complete output from command /usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-install-ftebqf7v/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/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-record-8vlws6dw/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_pswindows.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_common.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_psosx.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_psbsd.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_psaix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_pslinux.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_compat.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_psposix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    copying psutil/_pssunos.py -> build/lib.macosx-10.14-x86_64-3.7/psutil
    creating build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.macosx-10.14-x86_64-3.7/psutil/tests
    running build_ext
    building 'psutil._psutil_osx' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    creating build/temp.macosx-10.14-x86_64-3.7/psutil
    creating build/temp.macosx-10.14-x86_64-3.7/psutil/arch
    creating build/temp.macosx-10.14-x86_64-3.7/psutil/arch/osx
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_common.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_common.o
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_posix.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_posix.o
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=561 -DPSUTIL_OSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c psutil/_psutil_osx.c -o build/temp.macosx-10.14-x86_64-3.7/psutil/_psutil_osx.o
    In file included from psutil/_psutil_osx.c:36:
    In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:
    In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
    /usr/local/include/Block.h:16:3: error: Never include this file directly. Use <lzma.h> instead.
    #       error Never include this file directly. Use <lzma.h> instead.
            ^
    /usr/local/include/Block.h:93:2: error: unknown type name 'lzma_check'
            lzma_check check;
            ^
    /usr/local/include/Block.h:148:2: error: unknown type name 'lzma_vli'
            lzma_vli compressed_size;
            ^
    /usr/local/include/Block.h:172:2: error: unknown type name 'lzma_vli'
            lzma_vli uncompressed_size;
            ^
    /usr/local/include/Block.h:200:2: error: unknown type name 'lzma_filter'
            lzma_filter *filters;
            ^
    /usr/local/include/Block.h:217:20: error: use of undeclared identifier 'LZMA_CHECK_SIZE_MAX'
            uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
                              ^
    /usr/local/include/Block.h:231:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int3;
            ^
    /usr/local/include/Block.h:232:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int4;
            ^
    /usr/local/include/Block.h:233:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int5;
            ^
    /usr/local/include/Block.h:234:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int6;
            ^
    /usr/local/include/Block.h:235:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int7;
            ^
    /usr/local/include/Block.h:236:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int8;
            ^
    /usr/local/include/Block.h:237:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum1;
            ^
    /usr/local/include/Block.h:238:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum2;
            ^
    /usr/local/include/Block.h:239:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum3;
            ^
    /usr/local/include/Block.h:240:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum4;
            ^
    /usr/local/include/Block.h:261:2: error: unknown type name 'lzma_bool'
            lzma_bool ignore_check;
            ^
    /usr/local/include/Block.h:263:2: error: unknown type name 'lzma_bool'
            lzma_bool reserved_bool2;
            ^
    /usr/local/include/Block.h:264:2: error: unknown type name 'lzma_bool'
            lzma_bool reserved_bool3;
            ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-install-ftebqf7v/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/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-record-8vlws6dw/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/sq/hm4m826d5hl9n9v8ghsz2xvm0000gn/T/pip-install-ftebqf7v/psutil/
bug macos

Most helpful comment

The issue was that there were a lot of unbrewed header files found in /usr/local/include after migrating my Mac OS X. I ran brew doctor and it gave me a list of these header files, deleting them fixed the issue.

All 3 comments

Don't have this OSX version to test against. Perhaps this is due to lzma headers not installed?

The headers are installed. Any ideas?

$ sudo find /usr -name lzma.h -print
/usr/local/include/lzma.h
/usr/local/opt/include/lzma.h
/usr/local/Cellar/xz/5.2.2/include/lzma.h
/usr/local/Cellar/xz/5.2.4/include/lzma.h

The issue was that there were a lot of unbrewed header files found in /usr/local/include after migrating my Mac OS X. I ran brew doctor and it gave me a list of these header files, deleting them fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings