junto
Posts: 4
Joined: Sat Feb 14, 2015 5:25 pm

GoPiGo - smbus - No module found

Sat Feb 14, 2015 6:05 pm

I have been attempting to get the GoPiGo (dexter industries) to run on the raspberrypi B+ (CanaKit). Both were given as a gift. I am to the point to run the python script basic_test_all.py. This script fails and have been struggling to resolve. Included is some diagnostics I have picked up along the way. I don't think it matters yet, but the raspberrypi is connected to the control board and the switch on the control board is on.

Code: Select all

[email protected] ~ $ python -V
Python 2.7.3

Code: Select all

[email protected] ~ $ apt-cache search smbus
python-smbus - Python bindings for Linux SMBus access through i2c-dev
pypy-smbus-cffi - This Python module allows SMBus access through the I2C /dev

Code: Select all

[email protected] ~ $ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.VERSION
'0.5.10'

Code: Select all

[email protected] ~ $ sudo python basic_test_all.py
Traceback (most recent call last):
  File "basic_test_all.py", line 2, in <module>
    from gopigo import *
  File "/home/pi/gopigo.py", line 33, in <module>
    bus = smbus.SMBus(0) 
IOError: [Errno 2] No such file or directory
In attempting to diagnose this failure, I decided to write a test script called test.py:

Code: Select all

print "start----------------"
import RPi.GPIO as GPIO
import sys
import smbus

# for RPI version 1, use "bus = smbus.SMBus(0)"
rev = GPIO.RPI_REVISION
print "GPIO.RPI_REVISION=", rev
bus = smbus.SMBus(0)
print "Success"
print "end ----------------"
Here is the output:

Code: Select all

[email protected] ~ $ sudo python test.py
start----------------
GPIO.RPI_REVISION= 3
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    bus = smbus.SMBus(0)
IOError: [Errno 2] No such file or directory

Any help is greatly appreciated!!!!

karan259
Posts: 8
Joined: Thu Oct 24, 2013 3:38 am

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 7:06 am

Looks like the problem you are facing is because the library is trying to smbus(0), whereas it should be using smbus(1). You can try running the install script here: https://github.com/DexterInd/GoPiGo/blo ... n/setup.py by running

Code: Select all

python setup.py install
and that should solve the problem.

There is also a forum here: http://www.dexterindustries.com/forum/where you can ask your questions about the Dexter Industries products.

junto
Posts: 4
Joined: Sat Feb 14, 2015 5:25 pm

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 1:27 pm

I have run that setup.py script. Neither SMBus(0) nor SMBus(1) seems to work. However, when I change it to SMBus() it gets beyond this setup and is followed up by an IOError further down the script.

DirkS
Posts: 9940
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 1:45 pm

Which distro + version do you have?
The way i2c is enabled has changed with kernel version 3.18; see http://www.raspberrypi.org/forums/viewt ... 28&t=97314

junto
Posts: 4
Joined: Sat Feb 14, 2015 5:25 pm

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 2:21 pm

I am currently not on the device, but when I login, is the command for distro version the following?
cat /etc/os-release

Also, in attempting to diagnose this issue I looked for errors when booting up. I noticed the only FATAL error was on spi-dev module not found. Would that be related to this issue?

DirkS
Posts: 9940
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 2:31 pm

junto wrote:I am currently not on the device, but when I login, is the command for distro version the following?
cat /etc/os-release
That does not give the kernel version.
Use 'uname -a'
Also, in attempting to diagnose this issue I looked for errors when booting up. I noticed the only FATAL error was on spi-dev module not found. Would that be related to this issue?
No, don't think that it's directly related.

User avatar
dexterindustries
Posts: 47
Joined: Thu Mar 07, 2013 3:51 am
Location: Somewhere
Contact: Website

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 9:25 pm

I think we have a solution for this, if the problem is the kernel. If you've updated the kernel, in addition to the update, upgrade, dist-upgrade, we had to do the following to get some hardware to work.

Open your config.txt file:

Code: Select all

sudo nano /boot/config.txt
add the following at the bottom:

Code: Select all

"dtparam=i2c_arm=on"
Then save.

Then run

Code: Select all

sudo raspi-config
And select "Advanced Options", then option 7 I2c, and select "yes" to enable I2C.
John Cole
Dexter Industries

Code: Select all

http://www.dexterindustries.com

DirkS
Posts: 9940
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 9:28 pm

dexterindustries wrote:I think we have a solution for this, if the problem is the kernel. If you've updated the kernel, in addition to the update, upgrade, dist-upgrade, we had to do the following to get some hardware to work.

Open your config.txt file:

Code: Select all

sudo nano /boot/config.txt
add the following at the bottom:

Code: Select all

"dtparam=i2c_arm=on"
Then save.

Then run

Code: Select all

sudo raspi-config
And select "Advanced Options", then option 7 I2c, and select "yes" to enable I2C.
The raspi-config change should include changing dtparam in config.txt

User avatar
dexterindustries
Posts: 47
Joined: Thu Mar 07, 2013 3:51 am
Location: Somewhere
Contact: Website

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 9:29 pm

Sorry, so am I being redundant there then?
John Cole
Dexter Industries

Code: Select all

http://www.dexterindustries.com

DirkS
Posts: 9940
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: GoPiGo - smbus - No module found

Mon Feb 16, 2015 9:35 pm

dexterindustries wrote:Sorry, so am I being redundant there then?
Yes, I think so. I have not checked raspi-config myself, but came across http://www.raspberrypi.org/forums/viewt ... 56#p696131 today.

junto
Posts: 4
Joined: Sat Feb 14, 2015 5:25 pm

Re: GoPiGo - smbus - No module found

Tue Feb 17, 2015 3:23 am

It WORKED!!!

Just to close the loop.

Code: Select all

[email protected] ~ $ uname -a
Linux raspberrypi 3.18.5+ #744 PREEMPT Fri Jan 30 18:19:07 GMT 2015 armv6l GNU/Linux
The update to raspi-config did make the entry in the config.txt. I manually removed the duplicate.

I really appreciate the help. Thank you!!

User avatar
dexterindustries
Posts: 47
Joined: Thu Mar 07, 2013 3:51 am
Location: Somewhere
Contact: Website

Re: GoPiGo - smbus - No module found

Tue Feb 17, 2015 1:38 pm

Hey, awesome! Thanks for letting us know, this will definitely help me work through our own update. Really appreciate it!
John Cole
Dexter Industries

Code: Select all

http://www.dexterindustries.com

AdrianBoeh
Posts: 2
Joined: Sat Mar 21, 2015 12:33 pm

Re: GoPiGo - smbus - No module found

Sat Mar 21, 2015 1:28 pm

Hello all,

I was not able to use the above to solve, what I believed was the same issue (clearly not).
I am also not sure how to do the nice code example used above, not even sure how to copy/paste out of my SSH window to show.
I am very new to Linux, GoPiGO, and RaspberryPi... but have been code in Python for a couple years.

Presentation of issue (same as above):
[email protected] ~ $ cd /home/pi/GoPiGo/Software/Python
[email protected] ~ $ sudo python basic_test_all.py
Traceback (most recent call last):
File "basic_test_all.py", line 2, in <module>
from gopigo import *
File "home/pi/GoPiGo/Software/Python/gopigo.py", line 18, in <module>
import smbus
ImportError: No module name smbus

I have run
sudo apt-get update
sudo apt-get upgrade

I tried this...
https://github.com/bivab/smbus-cffi/issues/3

I can't import smbus via python

Python version 2.7.3
GPIO version 0.5.11
"dtparam=i2c_arm=on" is at the bottom of my config file and I made the advanced options changes

I tried restarting...

I tried directly installing smbus-cffi (also installed python easy_install). But after I cloned and tried to 'python setup.py install' it said there was no libffi package... https://pypi.python.org/pypi/smbus-cffi/0.4.1

User avatar
dexterindustries
Posts: 47
Joined: Thu Mar 07, 2013 3:51 am
Location: Somewhere
Contact: Website

Re: GoPiGo - smbus - No module found

Sat Mar 21, 2015 4:31 pm

Hey AdrianBoeh, not a problem at all and welcome to the Raspberry Pi and GoPiGo!

I think there's an easy solution, two possible ways to get you up and running quickly:

1). We have a startup procedure on our website spelled out here: http://www.dexterindustries.com/GoPiGo/ ... it/sdcard/

You may want to start out with Option 3, which is installing GoPiGo on your own image.

2). The much easier, but slightly more time consuming option, is to use the Dexter Industries Raspbian for Robots image on your SD card. It fits well onto a 4GB SD Card.

We have updated step-by-step instructions here: http://www.dexterindustries.com/howto/r ... n-sd-card/

And you can download it from Sourceforge here: http://sourceforge.net/projects/dexteri ... ianflavor/

Tell us how it goes!
John Cole
Dexter Industries

Code: Select all

http://www.dexterindustries.com

AdrianBoeh
Posts: 2
Joined: Sat Mar 21, 2015 12:33 pm

Re: GoPiGo - smbus - No module found

Sun Mar 22, 2015 1:16 am

Thank you so much! The little guy moves! :D

User avatar
dexterindustries
Posts: 47
Joined: Thu Mar 07, 2013 3:51 am
Location: Somewhere
Contact: Website

Re: GoPiGo - smbus - No module found

Sun Mar 22, 2015 1:20 am

Great to hear! Excellent!
John Cole
Dexter Industries

Code: Select all

http://www.dexterindustries.com

Return to “Beginners”