Python GPIO Error

1,575 views
Skip to first unread message

ikeg...@gmail.com

unread,
Aug 2, 2013, 3:51:54 PM8/2/13
to beagl...@googlegroups.com
Greetings. I ssh into my BB_B and I have followed this guide and everything works fine. However when I try typing this code to test my installation it doesn't work: 
  1. python -c "import Adafruit_BBIO.GPIO as GPIO; print GPIO"

I get an error:

root@beaglebone:~/adafruit-beaglebone-io-python# python blink.py Traceback (most recent call last): File "blink.py", line 1, in <module> import Adafruit_BBIO.GPIO as GPIO ImportError: No module named GPIO


root@beaglebone:~/adafruit-beaglebone-io-python# python -c "import Adafruit_BBIO.GPIO as GPIO; print GPIO"
Traceback (most recent call last):
 
File "<string>", line 1, in <module>
ImportError: No module named GPIO
root@beaglebone
:~/adafruit-beaglebone-io-python#

I tried to move along in the guide and typed this code into a new python file called blink.py:

import Adafruit_BBIO.GPIO as GPIO
import time
 
GPIO
.setup("P8_10", GPIO.OUT)
 
while True:
 GPIO
.output("P8_10", GPIO.HIGH)
 time
.sleep(0.5)
 GPIO
.output("P8_10", GPIO.LOW)
 time
.sleep(0.5)



When I try to run blink.py I get a similar error to the one above:

root@beaglebone:~/adafruit-beaglebone-io-python# python blink.py Traceback (most recent call last): File "blink.py", line 1, in <module> import Adafruit_BBIO.GPIO as GPIO ImportError: No module named GPIO


So I know something is up with my GPIO ports but I just do not know what. Please help me.
Thanks for reading

James Ronald

unread,
Aug 2, 2013, 4:36:41 PM8/2/13
to beagl...@googlegroups.com
See if Adafruit_BBIO installs correctly by running following commands separately:

opkg update

opkg install python-pip python-setuptools python-smbus

pip install Adafruit_BBIO


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

markd...@gmail.com

unread,
Aug 21, 2013, 1:15:08 AM8/21/13
to beagl...@googlegroups.com, ikeg...@gmail.com
Changing the current directory should help.

Python is loading Adafruit_BBIO from the current (source) directory, which only contains the __init__.py file.   By changing the current directory, it will load it from the correct (installed) area, which contains the other pieces (such as GPIO.so)

msrir...@gmail.com

unread,
Jul 14, 2016, 9:07:02 AM7/14/16
to BeagleBoard, ikeg...@gmail.com

I am using Beaglebone Black to run ultrasonic sensor. I am using the following code.

#!/usr/bin/env python
 
import BBIO.GPIO as GPIO                    # Import GPIO library
import time                                # Import time library
GPIO.setmode(GPIO.BCM)                     # Set GPIO pin numbering 
 
TRIG = 23                                  # Associate pin 23 to TRIG
ECHO = 24                                  # Associate pin 24 to ECHO
 
print "Distance measurement in progress"
 
GPIO.setup(TRIG, GPIO.OUT)                  # Set pin as GPIO out
GPIO.setup(ECHO, GPIO.IN)                   # Set pin as GPIO in
 
while True:
 
    GPIO.output(TRIG, False)                 # Set TRIG as LOW
    print "Waitng For Sensor To Settle"
    time.sleep(2)                            # Delay of 2 seconds
 
    GPIO.output(TRIG, True)                  # Set TRIG as HIGH
    time.sleep(0.00001)                      # Delay of 0.00001 seconds
    GPIO.output(TRIG, False)                 # Set TRIG as LOW
 
while GPIO.input(ECHO) == 0:               # Check whether the ECHO is LOW
    pulse_start = time.time()              # Saves the last known time of LOW pulse
 
while GPIO.input(ECHO) == 1:               # Check whether the ECHO is HIGH
 
    pulse_end = time.time()                # Saves the last known time of HIGH pulse 
 
    pulse_duration = pulse_end - pulse_start # Get pulse duration to a variable
 
    distance = pulse_duration * 17150        # Multiply pulse duration by 17150 to get distance
    distance = round(distance, 2)            # Round to two decimal points
 
    if distance > 2 and distance < 400:      # Check whether the distance is within range
        print "Distance:",distance - 0.5,"cm"  # Print distance with 0.5 cm calibration
    else:
        print "Out Of Range"                   # display out of range

While I try to implement it using the Beaglebone Black I am getting the following error.

"Traceback (most recent call last):
  File "ult.py", line 5, in <module>
    import BBIO.GPIO as GPIO                    # Import GPIO library
ImportError: No module named BBIO.GPIO"

I need help.

Peter Lawler

unread,
Jul 17, 2016, 7:46:29 PM7/17/16
to beagl...@googlegroups.com, ikeg...@gmail.com, msrir...@gmail.com


On 14/07/16 22:40, msrir...@gmail.com wrote:
> While I try to implement it using the Beaglebone Black I am getting the
> following error.
> "Traceback (most recent call last):
> File "ult.py", line 5, in <module>
> import BBIO.GPIO as GPIO # Import GPIO library
> ImportError: No module named BBIO.GPIO"
>
> I need help.
>

You do not say whether you have done this and are getting the error, but
have you installed the BBIO python library?

https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/overview

Cheers,

Pete.

Kelechi Ikegwu

unread,
Jul 18, 2016, 10:33:46 AM7/18/16
to Peter Lawler, beagl...@googlegroups.com, msrir...@gmail.com
Hi,

Can you please not include me in future messages.

Thanks,
KC

robert...@hotmail.com

unread,
Jul 14, 2017, 7:25:06 AM7/14/17
to BeagleBoard, ikeg...@gmail.com, markd...@gmail.com
Hi I have the same problem but I don't know how to change the directory you mentioned, would you tell me how should I do it?
Reply all
Reply to author
Forward
0 new messages