question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MacOS M1] Can not install via pip

See original GitHub issue

Summary

  • OS: MacOS 12.5
  • Architecture: arm64
  • Psutil version: 5.9.1
  • Python version: 3.9.10
  • Type: installation

Description

bin/pip install psutil fails:

Collecting psutil
  Using cached psutil-5.9.1.tar.gz (479 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: psutil
  Building wheel for psutil (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
…
  In file included from psutil/_psutil_osx.c:31:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:49:
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOTypes.h:81:49: error: expected ';' after top level declarator
  typedef mach_vm_address_t       IOVirtualAddress __kernel_ptr_semantics;
                                                  ^
  In file included from psutil/_psutil_osx.c:31:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:52:
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/OSMessageNotification.h:120:53: error: expected ';' after top level declarator
  typedef natural_t OSAsyncReference[kOSAsyncRefCount] __kernel_ptr_semantics;
                                                      ^
  psutil/_psutil_osx.c:102:17: warning: format specifies type 'long' but the argument has type 'pid_t' (aka 'int') [-Wformat]
                  pid, err, errno, mach_error_string(err));
                  ^~~
  psutil/_psutil_common.h:111:21: note: expanded from macro 'psutil_debug'
      fprintf(stderr, __VA_ARGS__); \
                      ^~~~~~~~~~~
  200 warnings and 2 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil which use PEP 517 and cannot be installed directly

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
nw-ctcommented, Aug 19, 2022

We’re also getting a similar error - (IOKit/IOKitLib.h file not found)

Running with macOS version 12.5.1 (Apple M1)

  • Installing psutil (5.9.1): Failed

  EnvCommandError

  Command ['/Users/happy/Library/Caches/pypoetry/virtualenvs/server-SivvDSJ0-py3.9/bin/pip', 'install', '--no-deps', 'file:///Users/happy/Library/Caches/pypoetry/artifacts/ea/f1/eb/b46bae20206f1195d2d5e2584957896c44df5ad31dda53841e6ea8fd7e/psutil-5.9.1.tar.gz'] errored with the following return code 1, and output: 
  Processing /Users/happy/Library/Caches/pypoetry/artifacts/ea/f1/eb/b46bae20206f1195d2d5e2584957896c44df5ad31dda53841e6ea8fd7e/psutil-5.9.1.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Building wheels for collected packages: psutil
    Building wheel for psutil (pyproject.toml): started
    Building wheel for psutil (pyproject.toml): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Users/happy/Library/Caches/pypoetry/virtualenvs/server-SivvDSJ0-py3.9/bin/python /Users/happy/Library/Caches/pypoetry/virtualenvs/server-SivvDSJ0-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpxdd56_7q
         cwd: /private/tmp/pip-req-build-c57iv8zl
    Complete output (51 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-arm64-cpython-39
    creating build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_pswindows.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_common.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/__init__.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_psosx.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_psbsd.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_psaix.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_pslinux.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_compat.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_psposix.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    copying psutil/_pssunos.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil
    creating build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/runner.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_memleaks.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/foo.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    copying psutil/tests/test_testutils.py -> build/lib.macosx-10.6-arm64-cpython-39/psutil/tests
    running build_ext
    building 'psutil._psutil_osx' extension
    creating build/temp.macosx-10.6-arm64-cpython-39
    creating build/temp.macosx-10.6-arm64-cpython-39/psutil
    creating build/temp.macosx-10.6-arm64-cpython-39/psutil/arch
    creating build/temp.macosx-10.6-arm64-cpython-39/psutil/arch/osx
    clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=591 -DPSUTIL_OSX=1 -I/Users/happy/Library/Caches/pypoetry/virtualenvs/server-SivvDSJ0-py3.9/include -I/nix/store/wcmyw7rvadybk5cdcdd7xghwbzk2p44w-python3-3.9.9/include/python3.9 -c psutil/_psutil_common.c -o build/temp.macosx-10.6-arm64-cpython-39/psutil/_psutil_common.o
    clang-11: warning: argument unused during compilation: '-fno-strict-overflow' [-Wunused-command-line-argument]
    clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=591 -DPSUTIL_OSX=1 -I/Users/happy/Library/Caches/pypoetry/virtualenvs/server-SivvDSJ0-py3.9/include -I/nix/store/wcmyw7rvadybk5cdcdd7xghwbzk2p44w-python3-3.9.9/include/python3.9 -c psutil/_psutil_osx.c -o build/temp.macosx-10.6-arm64-cpython-39/psutil/_psutil_osx.o
    clang-11: warning: argument unused during compilation: '-fno-strict-overflow' [-Wunused-command-line-argument]
    psutil/_psutil_osx.c:31:10: fatal error: 'IOKit/IOKitLib.h' file not found
    #include <IOKit/IOKitLib.h>
             ^~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/nix/store/hcgsj2j0a49kx0k1jrs7b55rb9yhwwil-clang-wrapper-11.1.0/bin/clang' failed with exit code 1
    ----------------------------------------
    ERROR: Failed building wheel for psutil
  Failed to build psutil

1reaction
tonycombocurvecommented, Oct 10, 2022

@ben9923 thanks for following up. i believe that i discovered the issue over the weekend. it had to do with xcode not being initialized. this small step ended up resolving the issue: xcodebuild -runFirstLaunch

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip install doesn't work on m1 Mac - Super User
I tried installing it with ensurepip as well as with the official get-pip.py script. With the official installation script I get a warning:...
Read more >
Pip install fails with M1 Mac #1221 - apple/coremltools - GitHub
Describe the bug Pip install for coremltools fails with M1 mac Numpy fails to build as a coremltools dependency Python 3.8.2, 3.8.10, 3.9, ......
Read more >
pip Command Not Found – Mac and Linux Error Solved
When using Python, you might need to install and use certain packages. And there is a command available for that known as 'pip'....
Read more >
Python pip installation on Mac is not working - Stack Overflow
Go to /Users/arnau/Library/Python/2.7/bin. Duplicate the files listed into /usr/local/bin/ so that the command-line can recognize your command, ...
Read more >
How to Install PIP on a Mac - groovyPost
Open the Mac Terminal app via the Launchpad. · In the Terminal, type python -m ensurepip or python3 -m ensurepip and press Enter....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found