Search code examples
pythonmacosinstallationpippsutil

Failed building wheel for psutil on macOS


Problem

I am trying to install psutil using pip so I ran pip install psutil but I receive the following error message:

Failed building wheel for psutil
Running setup.py clean for psutil


What I have tried

It seems like the problem is occurring during setup.py: Building wheel for psutil (setup.py) ... error.

I have tried running :

xcode-select --install

but I get the following error message:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

I have also tried:

sudo xcode-select --switch /Library/Developer/CommandLineTools

and

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Both work fine but even after restarting the terminal, I see no change.


And finally, I have tried running:

sudo xcode-select --reset

Which also makes no difference.


Solution

  • I just typed:

    sudo open /Library/Developer/CommandLineTools/SDKs
    

    into my terminal and it turns out that I have 2 versions of the Command Line SDK installed so it looked like this:

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

    I then just deleted the older MacOSX10.14.sdk and everything starting working correctly.

    Solution found here: https://github.com/giampaolo/psutil/issues/1632#issuecomment-564800186