# LED Alerter code fails to push to app

**URL:** <https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354>\
**Category:** Project help\
**Tags:** raspberrypi3\
**Created:** [April 8, 2020, 11:12pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354 "2020-04-08T23:12:45Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewnhem](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/andrewnhem/32/4284_2.png) [@andrewnhem](https://forums.balena.io/u/andrewnhem)\
**Post date:** [April 8, 2020, 11:12pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/1 "2020-04-08T23:12:45Z")

</div>

Tried pushing the LED alerter code to my app a few times. I keep seeing this:

```
[main] E: Unable to locate package rpi.gpio
[main] E: Couldn't find any package by glob 'rpi.gpio'
[main] E: Couldn't find any package by regex 'rpi.gpio'
[main] E: Unable to locate package python-rpi.gpio
[main] E: Couldn't find any package by glob 'python-rpi.gpio'
[main] E: Couldn't find any package by regex 'python-rpi.gpio'
[main]
[main] Removing intermediate container <redacted>
[main] The command '/bin/sh -c apt-get update && apt-get install -yq --no-install-recommends rpi.gpio python-dev python-rpi.gpio && apt-get clean && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
[Info] Uploading images
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: main
[Error] Error: The command '/bin/sh -c apt-get update && apt-get install -yq --no-install-recommends rpi.gpio python-dev python-rpi.gpio && apt-get clean && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
[Info] Built on arm01
[Error] Not deploying release.

```

Trying to build on Raspberry Pi3B+, on Windows 10.

---

<div class="post-metadata">

**Author:** ![andrewnhem](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/andrewnhem/32/4284_2.png) [@andrewnhem](https://forums.balena.io/u/andrewnhem)\
**Post date:** [April 8, 2020, 11:28pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/2 "2020-04-08T23:28:56Z")

</div>

Ah, I looked up other users who reported something similar and it turned out I shouldn’t have chosen the Raspberry Pi3 64-bit. Using the default one works. Newbie mistake here 🙂

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [July 2, 2021, 9:23am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/7 "2021-07-02T09:23:52Z")

</div>

Hello there,  
I am trying to use the RPi.GPIO to enable a LED on my board. I have added the  
`RUN pip3 install smbus2 paho-mqtt requests RPi.GPIO`  
But when I add in my code `import RPi.GPIO as GPIO` it returns

```auto
sensor File "/usr/lib/python3/dist-packages/RPi/GPIO/ __init__.py", line 23, in <module>
sensor from RPi._GPIO import *
sensor ModuleNotFoundError: No module named 'RPi._GPIO'

```

Have you solved this?

---

<div class="post-metadata">

**Author:** ![toochevere](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@toochevere](https://forums.balena.io/u/toochevere)\
**Post date:** [July 5, 2021, 9:54pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/8 "2021-07-05T21:54:54Z")

</div>

Hello @gmav. Thanks for your question.

You are using the 32 bit OS, as indicated above, correct?

Assuming that you are using the correct OS, it seems to me that the issue you see is in your build. I don’t normally program in Python, but the message would seem to indicate that it’s not really a there is something going on with the package manager and/or Python version.

I found two links that seem to talk about this. Do either of these help?

> <https://raspberrypi.stackexchange.com/questions/60774/importerror-no-module-named-rpi>

[https://www.raspberrypi.org/forums/viewtopic.php?t=275387](https://www.raspberrypi.org/forums/viewtopic.php?t=275387)

Please confirm that you are using the 32 bit OS and let us know if either of those links gets you unstuck.

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [July 9, 2021, 1:43pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/10 "2021-07-09T13:43:16Z")

</div>

Hello @toochevere  
I am using the balenaOS 2.71.3+rev5. I really don’t know if its the 32 bit OS, although when I build it repos the aarch64. I have done both the links above and still it can not go through the `import RPi.GPIO as GPIO`. Smbus works ok and its i2c!!!

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [July 9, 2021, 1:59pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/11 "2021-07-09T13:59:54Z")

</div>

Hi @gmav, what device are you using? Raspberry Pi 3 or 4? You can check if your OS is 32 or 64 bits by visiting the device page on the balenaCloud dashboard. If it says Raspberry Pi 4 or Raspberry Pi 3-64 then its 64bits, otherwise it’s 32.

Also, can you provide the full `Dockerfile.template` file?

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [July 9, 2021, 2:08pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/13 "2021-07-09T14:08:41Z")

</div>

Hi @tmigone,  
I am using a Raspberry Pi CM4 IO Board. The Arch is aarch64. The Dockerfile.template is:

```auto
FROM balenalib/%%BALENA_ARCH%%-debian-python

WORKDIR /usr/src/app

ENV INITSYSTEM on

RUN /usr/local/bin/python3.9 -m pip install --upgrade pip

RUN install_packages \

    nano \

    i2c-tools \

    kmod \

    libiio0 \

    libiio-utils \

    python3-libiio \

    python3-rpi.gpio \

    python-rpi.gpio \

    git \

    python3-dev \

    python-dev

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

COPY ./requirements.txt /requirements.txt

RUN pip install -r /requirements.txt

# COPY . /usr/src/app

# WORKDIR /usr/src/app

COPY *.py ./

COPY *.c ./

COPY *.json ./

ENV UDEV=on

CMD ["python3", "test_mk00.py"]

```

and the requirements.txt is:

```auto
smbus2
paho-mqtt
requests
RPi.Gpio

```

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [July 9, 2021, 2:36pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/14 "2021-07-09T14:36:03Z")

</div>

Hey, I found that for whatever reason installing RPI.GPIO from apt-get (which is what install\_packages does) results in the problem you are experiencing. If you remove `python3-rpi.gpio` and `python-rpi.gpio` from the install list, and then install it with pip then it works.

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [July 12, 2021, 7:22am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/16 "2021-07-12T07:22:53Z")

</div>

Hello @tmigone,  
Thank you for your reply… Your suggestion did work 🙂 . This is not correct to have happened. Or if its a bug in the procedure it should be mentioned somewhere. Thank you again for the help.

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [October 5, 2021, 11:19am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/18 "2021-10-05T11:19:46Z")

</div>

Hello again @tmigone,  
Since this morning, and although I haven’t changed my requirement list, it stopped working. Is there something done and I can not once more have a simple GPIO library to work with? This is the message I get when I try to build and upload:

```auto
[sensor] ERROR: Command errored out with exit status 1: /usr/local/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lne8jb3i/rpi-gpio_9a071875ba0a4d8a905cb78ac63f7f20/setup.py'"'"'; __file__ ='"'"'/tmp/pip-install-lne8jb3i/rpi-gpio_9a071875ba0a4d8a905cb78ac63f7f20/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)( __file__ ) if os.path.exists( __file__ ) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__ , '"'"'exec'"'"'))' install --record /tmp/pip-record-4nikewxl/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/RPi.Gpio Check the logs for full command output.

```

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [November 24, 2021, 1:42pm UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/20 "2021-11-24T13:42:07Z")

</div>

Hey, @gmav can you share your Dockerfile in here please?

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [June 5, 2024, 6:38am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/24 "2024-06-05T06:38:24Z")

</div>

any update to this? I have encountered the same problem. 64-bit. Not sure what base image to use but same as here Aarch64 on a RPi4B. How do we call GPIO?

---

<div class="post-metadata">

**Author:** ![gmav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gmav/32/6219_2.png) [@gmav](https://forums.balena.io/u/gmav)\
**Post date:** [June 5, 2024, 7:06am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/25 "2024-06-05T07:06:30Z")

</div>

Hi…  
I used on my Dockerfile.template the  
pip install RPi.GPIO==0.7.1a4

This helped and I could use the GPIO pins.

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [June 5, 2024, 10:38am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/26 "2024-06-05T10:38:29Z")

</div>

thanks for this.  
unfortunately, it didn’t work for me but I will keep working!

---

<div class="post-metadata">

**Author:** ![alanb128](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alanb128/32/2839_2.png) [@alanb128](https://forums.balena.io/u/alanb128)\
**Post date:** [June 21, 2024, 12:55am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/27 "2024-06-21T00:55:35Z")

</div>

Hello, what error are you seeing when you try to push the project to your device?

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [June 25, 2024, 12:50am UTC](https://forums.balena.io/t/led-alerter-code-fails-to-push-to-app/92354/28 "2024-06-25T00:50:39Z")

</div>

@alanb128 thanks for responding.  
I figured it out two weeks ago. I resolved the problem, i think, mostly by changing the base balena image.

[here](https://forums.balena.io/t/balenaos-rpi-and-hat-oled-rgb-and-fan/370476), if anyone else needs this info. good luck!
