Trouble running RPi.GPIO

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

Hi,

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

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 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

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

RUN apt-get update -y && apt-get install build-essential
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