ImportError: No module named smbus

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
codehub
 
Posts: 5
Joined: Wed Mar 19, 2014 6:06 am

ImportError: No module named smbus

Post by codehub »

I'm trying to follow the instructions for: https://learn.adafruit.com/adafruit-16x ... y-pi/usage

I'm running Python 2.7.5
Raspberry Pi: 512
When I run: sudo i2cdetect -y 1 it shows 20: 20 and everything looks fine.
When I run: sudo python Adafruit_CharLCDPlate.py
I get the following error:
Traceback (most recent call last):
File "Adafruit_CharLCDPlate.py", line 11, in <module>
from Adafruit_I2C import Adafruit_I2C
File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/Adafruit_I2C.py", line 3, in <module>
import smbus
ImportError: No module named smbus

I have run: sudo apt-get install python-smbus and it says that it was already installed.
When I run: pydoc smbus
it says: no Python documentation found for 'smbus'

Can anyone explain to me what I need to do to fix this error?

Thanks,

jk

User avatar
codehub
 
Posts: 5
Joined: Wed Mar 19, 2014 6:06 am

Re: ImportError: No module named smbus

Post by codehub »

simple fix.

$sudo python2.6 /path/to/python/file.py

Thanks anyway.

jk

jrwagner89
 
Posts: 4
Joined: Tue Apr 01, 2014 1:34 pm

Re: ImportError: No module named smbus

Post by jrwagner89 »

im having the same issue, how exactly did you fix this? when I run the line you posted i get "command not found"

User avatar
codehub
 
Posts: 5
Joined: Wed Mar 19, 2014 6:06 am

Re: ImportError: No module named smbus

Post by codehub »

What version of Python are you running?

jrwagner89
 
Posts: 4
Joined: Tue Apr 01, 2014 1:34 pm

Re: ImportError: No module named smbus

Post by jrwagner89 »

Im running python 2, i dont know the exact version until I can get home and check this evening. Ill update.

jrwagner89
 
Posts: 4
Joined: Tue Apr 01, 2014 1:34 pm

Re: ImportError: No module named smbus

Post by jrwagner89 »

2.7.3

User avatar
codehub
 
Posts: 5
Joined: Wed Mar 19, 2014 6:06 am

Re: ImportError: No module named smbus

Post by codehub »

Ok, a few things to try:

$ sudo apt-get update
$ sudo apt-get upgrade

Then

$ sudo apt-get install python-dev python-smbus

Let me know if that helps.

jrwagner89
 
Posts: 4
Joined: Tue Apr 01, 2014 1:34 pm

Re: ImportError: No module named smbus

Post by jrwagner89 »

that did help, now Im just getting errors acessing my I2C addressed, I might have the accelerometer hooked up wrong tho. Thanks!

User avatar
RossU
 
Posts: 15
Joined: Tue Jun 21, 2016 2:28 pm

Re: ImportError: No module named smbus

Post by RossU »

I did the sudo get-apt install described but it is a Python 2 module and I´m using a python 3 so it isn´t updating the correct development environment. Is there an equivalent package for python 3?

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”