error while installing RPi.GPIO as "ERROR: Command errored out with exit status 1:"

i was trying to install rpi.gpio on raspberry pi 4 with ubuntu 20.10 desktop as follows

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip python-dev

it gave as

note, selecting 'python-dev-is-python2' instead of 'python-dev'
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it: python3-pip

so i tried

 sudo apt-get install python3-pip python-dev

which installed it normally but then, for

sudo pip install RPi.GPIO 

which gives really big error as starting with

ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-00y2fso0/"'"'; __file__='"'"'/tmp/pip-install-00y2fso0/"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-m2w0m0n7 cwd: /tmp/pip-install-00y2fso0/

and ending with

 collect2: error: ld returned 1 exit status error: command 'aarch64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for RPi.GPIO

it again ran setup as

 Running setup.py clean for RPi.GPIO
Failed to build RPi.GPIO
Installing collected packages: RPi.GPIO
Running setup.py install for RPi.GPIO ... error

failing with

error: command 'aarch64-linux-gnu-gcc' failed with exit status 1 ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-00y2fso0/"'"'; __file__='"'"'/tmp/pip-install-00y2fso0/"'"';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-u3ttxsed/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/RPi.GPIO
Check the logs for full command output.

i found this somewhere and tried

sudo apt install rpi.gpio-common

which installed normally,please help me with this error and can I use this 'rpi.gpio-common' to control gpio pins if yes how? thanks for your time.

4

3 Answers

I was able to fix the issue by installing RPi.gpio using pip3. Type the following commands:

export CFLAGS=-fcommon
pip3 install RPi.GPIO

Source:

3

As of version 20.10, Ubuntu does not come with Python 2 installed as it is deprecated. It does have python 3. You use python3 to run python and pip3 to install modules.

DISCLAIMER:I am pretty new at using Ubuntu/Linux and Raspberry Pi, so I am not super knowledgeable about any of these systems or why things work a certain way. I'm going to give it a shot though since I haven't seen any other answers and I was having the same issue.


TL;DR

try:

sudo apt-get install RPi.GPIO

I think it may have something to do with pip not working for some reason.


Background

So for background, I have a python script that I was running on the Raspbian OS to measure the CPU temperature and control a few LEDs using the GPIO pins, but I needed a 64 bit operating system for some software and ended up going with lubuntu.

I did pretty much all the same steps as you and had the same errors. I think it was something to do with pip, because once I ran the above command it started working.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like