Thank you to all the contributors with their posts correlating to **RPI.GPIO**. I have tried most of your suggestions but so far to no avail.
My current version: 0.7.1a4, I'm running bullseye on Pi4 and a python3 programm which should **import the RPi.GPIO as GPIO**. Instead I get: ModuleNotFoundError: No module named 'RPi.GPIO'; 'RPi' is not a package`.
On a bullseye headless the same program imports **RPi.GPIO as GPIO** without a problem.
I have tried various RPi.GPIO installation methods and am receiving as many different messages in return. But nothing so far has solved anything. And now I am without a clue as to where to look or do next.
Method 1:
sudo pip3 install numpy --extra-index-url https://www.piwheels.org/simple
message returned:
Requirement already satisfied: ...dist-packages (1.19.5)
Method 2:
pip install RPi.GPIO
message returned:
Defaulting to user installation because normal site-packages is not
writeableRequirement already satisfied
Method 3:
pip3 install RPi.GPIO
message returned:
Requirement already satisfied: ...dist-packages
(0.7.1a4)
Method 4:
export CFLAGS=-fcommon
pip3 install RPi.GPIO
message returned:
Defaulting to user installation because normal site-packages is not
writeableRequirement already satisfied: ...dist-packages(0.7.1a4)
Method 5:
sudo apt-get -y install python3-rpi.gpio
message returned:
...already the newest version
(0.7.0-0.2+b1).
Method 6:
sudo apt-get update && sudo apt-get install python-rpi.gpio python3-rpi.gpio
message returned:
python3.rpi.gpiois 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
Method 7:
sudo apt-get install RPi.GPIO
message returned:
Note, selecting '
python3-rpi.gpio' for regex 'RPi.GPIO' Note, selecting 'python-rpi.gpio' for regex 'RPi.GPIO' Note, selecting 'rpi.gpio-common' for regex 'RPi.GPIO'python3-rpi.gpiois already the newest version(0.7.0-0.2+b1).rpi.gpio-commonis already the newest version(0.7.0-0.2+b1).
Thank you for your suggestions & help
I was with the same error, try all the commands and nothing but now I succeed, I hope it helps you, I just put python3 when reading the code from the console, for example: 'sudo python3 testgpio.py' instead of just python, I hope it serves you
Try this:
import RPi.GPIO as GPIO
Replace RPI.GPIO with RPi.GPIO, the letter i in lowercase, because python is case sensitive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With