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

1
  • It may be broken on jessie. It requires Python < 3.3 but jessie uses Python 3.4.2.
    – joan
    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.

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.

0
pip install RPi.GPIO

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.