Can't Install psutil
Asked Answered
M

2

8

Can someone help me understand why I can't install psutil? I'm on MacOS. I'm a noob so bear with me, but any help would be appreciated. Could it be something to do with the default Python install vs v3 that I installed? I'm new to command line so confused about what is causing the error and how to fix it...

This is the error message I get...

kasey@MacBook-Pro ~ % pip3 install psutil
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting psutil
  Downloading psutil-5.7.0.tar.gz (449 kB)
     |████████████████████████████████| 449 kB 150 kB/s
Building wheels for collected packages: psutil
  Building wheel for psutil (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/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/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-wheel-dsejsf
       cwd: /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/
  Complete output (43 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.15-x86_64-2.7
  creating build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_pswindows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_common.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_psosx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_psbsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_psaix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_pslinux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_compat.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_psposix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  copying psutil/_pssunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
  creating build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/runner.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_aix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
  running build_ext
  building 'psutil._psutil_osx' extension
  creating build/temp.macosx-10.15-x86_64-2.7
  creating build/temp.macosx-10.15-x86_64-2.7/psutil
  creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch
  creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch/osx
  cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_OSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c psutil/_psutil_common.c -o build/temp.macosx-10.15-x86_64-2.7/psutil/_psutil_common.o
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  error: command 'cc' failed with exit status 1
  ----------------------------------------
  ERROR: 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
    ERROR: Command errored out with exit status 1:
     command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/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/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-record-O5uazE/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/kasey/Library/Python/2.7/include/python2.7/psutil
         cwd: /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/
    Complete output (43 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-2.7
    creating build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_pswindows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_common.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_psosx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_psbsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_psaix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_pslinux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_compat.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_psposix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    copying psutil/_pssunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
    creating build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/runner.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
    running build_ext
    building 'psutil._psutil_osx' extension
    creating build/temp.macosx-10.15-x86_64-2.7
    creating build/temp.macosx-10.15-x86_64-2.7/psutil
    creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch
    creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch/osx
    cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_OSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c psutil/_psutil_common.c -o build/temp.macosx-10.15-x86_64-2.7/psutil/_psutil_common.o
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    error: command 'cc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/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/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-record-O5uazE/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/kasey/Library/Python/2.7/include/python2.7/psutil Check the logs for full command output.
Multilingual answered 4/3, 2020 at 9:46 Comment(2)
See this question: #52523065Constanceconstancia
Just realized I didn't have XCode installed....Multilingual
K
10

This happens when you have multiple versions installed (as for me, I had python 3.5 along with 3.7 installed), you have to specify a granular version, like so (for 3.7):

sudo apt-get install python3.7-dev -y

Read more: https://github.com/giampaolo/psutil/issues/1143#issuecomment-334695523

Kamat answered 20/7, 2020 at 19:38 Comment(0)
F
0

For the same issue on AWS for python3, you will likely need to specify the version more explicitly:

yum install python36-devel.x86_64

Or just search for the right package name:

yum search python | grep -i dev
Feverous answered 26/8, 2020 at 1:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.