Having trouble installing RPi.GPIO module in python

from pip, building the wheel fails, and if I try to build it from setup.py I get:

gcc: error: unrecognized command line option '-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a72_musl/Python-3.9.4=Python-3.9.4'

Is anybody familiar with this error? I am just a beginner at this, I want to experiment with driving a display and buttons (which I already got working in RPi OS).

Thank you.

You must install python-dev for the build to work

I installed python3-dev with opkg (no errors) but unfortunately I am still getting exactly the same errors, both when trying to install from pip, and when trying to install with setup.py.

Now I must point out that at this moment the RPi 4B build of OpenWRT is still in daily snapshot phase. Could this have to do with it?

negative... 21.02.0-rc1 phase and no... it won't make any difference to your symtomatology...

Until i can fix it, I am looking into other gpio modules. I found a real simple one that uses sysfs and is easy to control , I only need the gpio lines for the additional lines on an SPI mini lcd display (1.44") - DC/reset/LED. PWM isn't needed - yet.

Nonetheless, thank you (all) for the help.

1 Like

did you manage to fix this?

root@OpenWrt:~/RPi.GPIO-0.7.1# python3 setup.py install
running install
/usr/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing RPi.GPIO.egg-info/PKG-INFO
writing dependency_links to RPi.GPIO.egg-info/dependency_links.txt
writing top-level names to RPi.GPIO.egg-info/top_level.txt
reading manifest file 'RPi.GPIO.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching '.hg'
adding license file 'LICENCE.txt'
writing manifest file 'RPi.GPIO.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-aarch64/egg
running install_lib
running build_py
running build_ext
building 'RPi._GPIO' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/include -fcommon -fPIC -I/usr/include/python3.9 -c source/c_gpio.c -o build/temp.linux-aarch64-3.9/source/c_gpio.o
gcc: error: unrecognized command line option '-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10'
gcc: error: unrecognized command line option '-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10'
gcc: error: unrecognized command line option '-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10'
error: command '/usr/bin/gcc' failed with exit code 1
root@OpenWrt:~/RPi.GPIO-0.7.1#

It seems to be related to : gcc: error: unrecognized command line option '-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.9.10=Python-3.9.10'

Others have commented on.

I have found a solution after about an hour of help from Paul Fertser!

You need to:

opkg install python3-base-src

and then edit "/usr/lib/python*/_sysconfigdata.py" and remove all lines matching:

'-ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-*=Python-*' (replace * with the version on your system.

Than I did "pip3 install -U pip wheel setuptools" for good measure.
Finally: python3 -m pip install rpi.gpio worked great.

2 Likes

takes off my hat and bows :scream:

1 Like

I now have a nice 240px adafruit tft working on my pi3!epic! :wink:

1 Like

Brilliant! That did it.
I only had to find out how to decompress the source:
tar -xvzf RPi.GPIO-0.7.1.tar.gz
cd to folder:
cd RPI.GPIO-0.7.1
and do this below as the decompression didn't leave timestamps on the files:
$ touch find . -type f
Then
python3 setup.py install
worked.

It solved my other problem with pip install spidev as well, so it's a good to know feature! :slight_smile:

1 Like

Bit late back to the party, but hat off to this solution. I am certainly going to try this route again, but I did manage to get extra leds working in Openwrt by adding them in the DTS file before building. I had 9 leds available which could be directly programmed with the default LED config in LUCI.
This solution here will also enable me to drive an SPI display in OpenWRT.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.