Raspberry Pi2 B, standard Raspbian. Using RPi.GPIO, V3 installed as:
sudo apt-get install python-rpi.gpio python3-rpi.gpio
On line
import RPi.GPIO
I get
ImportError: /usr/local/lib/python3.2/dist-packages/RPi/GPIO.so: undefined symbol: _Py_ZeroStruct
(either in interpreter or as code run as python3 myCode.py).
Any help please!?
asked May 4, 2015 at 7:19
-
It may be broken on jessie. It requires Python < 3.3 but jessie uses Python 3.4.2.joan– joan2015年05月04日 13:13:25 +00:00Commented May 4, 2015 at 13:13
3 Answers 3
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) # set board mode to Broadcom
GPIO.setup(17, GPIO.OUT) # set up pin 17
GPIO.setup(18, GPIO.OUT) # set up pin 18
GPIO.output(17, 1) # turn on pin 17
GPIO.output(18, 1) # turn on pin 18
from here.
answered Jul 28, 2017 at 8:47
It might be that your Pi is not updated.
Go to the command line on your pi and enter:
sudo apt-get update
sudo apt-get upgrade
After running these commands, reinstall both the packages. It should work.
answered Jul 17, 2017 at 10:57
pip install RPi.GPIO