8

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!?

Ghanima
16k17 gold badges66 silver badges127 bronze badges
asked May 4, 2015 at 7:19
1
  • It may be broken on jessie. It requires Python < 3.3 but jessie uses Python 3.4.2. Commented May 4, 2015 at 13:13

3 Answers 3

1
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
0

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
0
pip install RPi.GPIO

From Here: https://pypi.org/project/RPi.GPIO/#description

answered May 17, 2018 at 0:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.