# Trouble running RPi.GPIO

**URL:** <https://forums.balena.io/t/trouble-running-rpi-gpio/200630>\
**Category:** General\
**Created:** [October 19, 2020, 2:45am UTC](https://forums.balena.io/t/trouble-running-rpi-gpio/200630 "2020-10-19T02:45:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidacarrollcoupons](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@davidacarrollcoupons](https://forums.balena.io/u/davidacarrollcoupons)\
**Post date:** [October 19, 2020, 2:45am UTC](https://forums.balena.io/t/trouble-running-rpi-gpio/200630/1 "2020-10-19T02:45:47Z")

</div>

I am trying to install RPi.GPIO for my Raspberry Pi 3 target build. I have installed Visual Studio 19 as described to enable py\_gpio.o to be compiled. But it fails by saying it can’t find gcc. Do you know how to ensure it knows how to get to the gcc compiler in Visual Studio? Thank you

[main] Installing collected packages: AWSIoTPythonSDK, wheel, colorzero, gpiozero, RPi.GPIO  
[main] Running setup.py install for AWSIoTPythonSDK: started  
[main] Running setup.py install for AWSIoTPythonSDK: finished with status ‘done’  
[main] Running setup.py install for RPi.GPIO: started  
[main] Running setup.py install for RPi.GPIO: finished with status ‘error’  
[main] ERROR: Command errored out with exit status 1:  
[main] command: /usr/local/bin/python3.5 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-lb88wlg6/RPi.GPIO/setup.py’"’"’; **file** =’"’"’/tmp/pip-install-lb88wlg6/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 /tmp/pip-record-sl0rtqzb/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.5m/RPi.GPIO  
[main] cwd: /tmp/pip-install-lb88wlg6/RPi.GPIO/  
[main] Complete output (16 lines):  
[main] running install  
[main] running build  
[main] running build\_py  
[main] creating build  
[main] creating build/lib.linux-armv7l-3.5  
[main] creating build/lib.linux-armv7l-3.5/RPi  
[main] copying RPi/ **init**.py -\> build/lib.linux-armv7l-3.5/RPi  
[main] creating build/lib.linux-armv7l-3.5/RPi/GPIO  
[main] copying RPi/GPIO/ **init**.py -\> build/lib.linux-armv7l-3.5/RPi/GPIO  
[main] running build\_ext  
[main] building ‘RPi.\_GPIO’ extension  
[main] creating build/temp.linux-armv7l-3.5  
[main] creating build/temp.linux-armv7l-3.5/source  
[main] gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.5m -c source/py\_gpio.c -o build/temp.linux-armv7l-3.5/source/py\_gpio.o  
[main] unable to execute ‘gcc’: No such file or directory  
[main] error: command ‘gcc’ failed with exit status 1  
[main] ----------------------------------------  
[main]  
[main] ERROR: Command errored out with exit status 1: /usr/local/bin/python3.5 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-lb88wlg6/RPi.GPIO/setup.py’"’"’; **file** =’"’"’/tmp/pip-install-lb88wlg6/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 /tmp/pip-record-sl0rtqzb/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.5m/RPi.GPIO Check the logs for full command output.  
[main]  
[main] WARNING: You are using pip version 20.1.1; however, version 20.2.4 is available.  
[main] You should consider upgrading via the ‘/usr/local/bin/python3.5 -m pip install --upgrade pip’ command.  
[main]  
[main] Removing intermediate container 5155146d168c  
[main] The command ‘/bin/sh -c pip install -r requirements.txt’ returned a non-zero code: 1  
[Info] Uploading images  
[Success] Successfully uploaded images  
[Error] Some services failed to build:  
[Error] Service: main  
[Error] Error: The command ‘/bin/sh -c pip install -r requirements.txt’ returned a non-zero code: 1  
[Info] Built on arm03  
[Error] Not deploying release.  
Remote build failed

---

<div class="post-metadata">

**Author:** ![nghiant2710](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nghiant2710](https://forums.balena.io/u/nghiant2710)\
**Post date:** [October 19, 2020, 7:09am UTC](https://forums.balena.io/t/trouble-running-rpi-gpio/200630/4 "2020-10-19T07:09:33Z")

</div>

Hi,

Can you please share with us your Dockerfile so we can have a look?

---

<div class="post-metadata">

**Author:** ![davidacarrollcoupons](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@davidacarrollcoupons](https://forums.balena.io/u/davidacarrollcoupons)\
**Post date:** [October 20, 2020, 5:41pm UTC](https://forums.balena.io/t/trouble-running-rpi-gpio/200630/6 "2020-10-20T17:41:22Z")

</div>

**HERE IS DOCKERFILE.TEMPLATE**

FROM balenalib/%%BALENA\_MACHINE\_NAME%%-python:3-stretch-run

# use `install_packages` if you need to install dependencies,

# for instance if you need git, just uncomment the line below.

# RUN install\_packages git

# Set our working directory

WORKDIR /usr/src/app

# Copy requirements.txt first for better cache on later pushes

COPY requirements.txt requirements.txt

# pip install python deps from requirements.txt on the [resin.io](http://resin.io) build server

RUN pip install -r requirements.txt

# This will copy all files in our root to the working directory in the container

COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.

ENV UDEV=1

# main.py will run when container starts up on the device

CMD [“python”,"-u",“src/main.py”]

**AND IN CASE THIS IS HELPFUL HERE IS REQUIREMENTS.TXT:**  
AWSIoTPythonSDK==1.0.0  
wheel  
gpiozero  
RPi.GPIO

---

<div class="post-metadata">

**Author:** ![samothx](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samothx](https://forums.balena.io/u/samothx)\
**Post date:** [October 20, 2020, 8:33pm UTC](https://forums.balena.io/t/trouble-running-rpi-gpio/200630/7 "2020-10-20T20:33:11Z")

</div>

Hi,  
the build worked for me using the Dockerfile.template below. Toolchain installation is in

```auto
RUN apt-get update -y && apt-get install build-essential

```

```auto
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3-stretch-run
# use install_packages if you need to install dependencies,
# for instance if you need git, just uncomment the line below.
RUN install_packages git
# Set our working directory

RUN apt-get update -y && apt-get install build-essential

WORKDIR /usr/src/app
# Copy requirements.txt first for better cache on later pushes

COPY requirements.txt requirements.txt
# pip install
# python deps from requirements.txt on the resin.io build server

RUN pip install -r requirements.txt
# This will copy all files in our root to the working directory in the container

COPY . ./
# Enable udevd so that plugged dynamic hardware devices show up in our container.

ENV UDEV=1
# main.py will run when container starts up on the device

CMD [“python”,"-u",“src/main.py”]

```

Hope this works for you …  
Regards Thomas
