Trying to install spidev on OS X with sudo pip install spidev

I get this error:

 sudo pip install spidev The directory '/Users/username/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/username/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting spidev Downloading spidev-3.2.tar.gz Installing collected packages: spidev Running setup.py install for spidev ... error Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-X8OufL/spidev/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-u6yhj6-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'spidev' extension creating build creating build/temp.macosx-10.6-intel-2.7 /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c spidev_module.c -o build/temp.macosx-10.6-intel-2.7/spidev_module.o spidev_module.c:25:10: fatal error: 'linux/spi/spidev.h' file not found #include <linux/spi/spidev.h> ^ 1 error generated. error: command '/usr/bin/clang' failed with exit status 1 ---------------------------------------- Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-X8OufL/spidev/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-u6yhj6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-X8OufL/spidev/ 

    1 answer 1

    No header files, can not compile the package. The necessary files are in python-dev:

     # python 2 brew install python-dev # python 3 brew install python3-dev 
    • Yes, in recent times, everything connected with pythons does not want to be installed .. even through IDE ... you need to reinstall it. - Insider
    • brew install python-dev ; brew install python3-dev - Insider
    • @Insider and that, did not help brew install python-dev ? - Nick Volynkin
    • Nah, I have something wrong with the axis itself .. - Insider
    • Damn, makos is the very case when it would be necessary to put a “minus”, but the hand does not rise to violate the semi-annual tradition. - aleksandr barakin