4

I am creating a server for the Raspberry Pi and I am partially writing the code using OS X. I need the RPi.GPIO module to make my script run, (even if I don't use it). After calling pip3 install RPi.GPIO I get following error:

    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c source/py_gpio.c -o build/temp.macosx-10.6-intel-3.5/source/py_gpio.o
    source/py_gpio.c:87:4: error: function definition is not allowed here
       {
       ^
    source/py_gpio.c:143:10: warning: implicit declaration of function 'cleanup_one' is invalid in C99 [-Wimplicit-function-declaration]
             cleanup_one();
             ^
    source/py_gpio.c:200:24: error: function definition is not allowed here
       int setup_one(void) {
                           ^
    source/py_gpio.c:293:13: warning: implicit declaration of function 'setup_one' is invalid in C99 [-Wimplicit-function-declaration]
           if (!setup_one())
                ^
    source/py_gpio.c:345:21: error: function definition is not allowed here
       int output(void) {
                        ^
    source/py_gpio.c:419:18: error: called object type 'PyObject *' (aka 'struct _object *') is not a function or function pointer
          if (!output())
               ~~~~~~^
    source/py_gpio.c:475:18: error: called object type 'PyObject *' (aka 'struct _object *') is not a function or function pointer
          if (!output())
               ~~~~~~^
    source/py_gpio.c:581:32: warning: comparison of integers of different signs: 'const int' and 'unsigned int' [-Wsign-compare]
          if (*(*pin_to_gpio+chan) == gpio)
              ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
    3 warnings and 5 errors generated.
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qv/z3csxhdd66qf95wp51zd3vrh0000gn/T/pip-build-_64gsisl/RPi.GPIO/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/qv/z3csxhdd66qf95wp51zd3vrh0000gn/T/pip-gdjkt_6z-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qv/z3csxhdd66qf95wp51zd3vrh0000gn/T/pip-build-_64gsisl/RPi.GPIO/

I've tried to install it by hand with similar result. What do I need to make this work?

4
  • Presuming RPi.GPIO links to a corresponding C library, you may be able to build that, but (I doubt it and) you won't be able to run code with it. That may then be okay if you just want to get your IDE or whatever to work while composing. However, if it doesn't link to such a library, i.e., all the C code is in the python module, this is probably it. A better option here is to work remotely via a mounted filesystem, and do whatever to get the IDE to find the module from there. If you don't like any of that, I'd just write a dummy version of RPi.GPIO. Might even have advantages...
    – goldilocks
    Jan 4, 2017 at 14:47
  • implicit declaration implies there's a header missing, meaning it is a missing C library. Dunno what RPi.GPIO is built on, but again, the chances of getting it to compile on OSX are slim to (most likely) none. It will certainly never run.
    – goldilocks
    Jan 4, 2017 at 14:49
  • Dummy version of this module might be a workaround. All in all I won't run anything in on my laptop requiring GPIO handling.
    – gonczor
    Jan 4, 2017 at 15:03
  • At a guess it's probably the fact that RPi.GPIO relies on epoll (for edge detection) which is Linux specific (Mac OS X has kqueue instead). So it'll probably compile on anything Linux-based (like Ubuntu), although it wouldn't work on anything but an RPi, but it won't even compile on a Mac
    – Dave Jones
    Jan 5, 2017 at 11:31

1 Answer 1

4

At first I didn't understand that the RPi library requires all this stuff that is particular to the Raspberry Pi environment (and is not expected to work on a dev environment say if you're working on a Mac).

For development in a different system a good alternative is to use a fake library.

I'm using this one: https://github.com/sn4k3/FakeRPi

and I'm using like this:

if app.env == 'development':
    import FakeRPi.GPIO as GPIO
else:
    import RPi.GPIO as GPIO

This one also seems promising: https://pypi.org/project/fake-rpi/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.