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?

Darth Vader
  • 4,218
  • 24
  • 47
  • 70
gonczor
  • 141
  • 1
  • 4

1 Answers1

5

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/

bubbassauro
  • 151
  • 1
  • 4