speendo
Posts: 13
Joined: Fri Sep 18, 2015 9:19 am

python3-smbus

Sat Oct 03, 2015 9:46 am

Hi!

I upgraded to Raspbian Jessie a couple of days ago. Now the python3-smbus package seems broken to me.

I installed python3-smbus:

Code: Select all

$ apt-cache show python3-smbus
Package: python3-smbus
Source: i2c-tools
Version: 3.1.1+svn-1
Architecture: armhf
Maintainer: Aurelien Jarno <[email protected]>
Installed-Size: 57
Depends: libc6 (>= 2.13-28)
Recommends: i2c-tools
Homepage: http://www.lm-sensors.org
Priority: extra
Section: python
Filename: pool/main/i/i2c-tools/python3-smbus_3.1.1+svn-1_armhf.deb
Size: 10546
SHA256: 9498ac82ad48e8d161d84740e86c80e6219faa5766e681be3536bdd56255c545
SHA1: 74ff862d433d30a2acc6cc280f4f0f04cada6a56
MD5sum: b9ee072acbbe4b024bb5309e8d8a2f92
Description: Python 3 bindings for Linux SMBus access through i2c-dev
 This Python module allows SMBus access through the I2C /dev interface on
 Linux hosts.  The host kernel must have I2C support, I2C device interface
 support, and a bus adapter driver.
Description-md5: f5de4474453d4a48c9f0e43b765f1fd9
However, it does not seem to work:

Code: Select all

$ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'smbus'
>>> exit()
Could somebody please confirm this for me?

If the package is really broken, how can I file a bug report?

Thank you!

User avatar
joan
Posts: 14470
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: python3-smbus

Sat Oct 03, 2015 10:11 am

Have you installed the package?

sudo apt-get install python3-smbus

speendo
Posts: 13
Joined: Fri Sep 18, 2015 9:19 am

Re: python3-smbus

Sat Oct 03, 2015 10:36 am

oh, right, you can't see that from my apt-cache output

Yes, it is installed:

Code: Select all

$ sudo aptitude search smbus
p   pypy-smbus-cffi                                                - This Python module allows SMBus access through the I2C /dev              
i   python-smbus                                                   - Python bindings for Linux SMBus access through i2c-dev                   
v   python2.6-smbus                                                -                                                                          
v   python2.7-smbus                                                -                                                                          
i   python3-smbus                                                  - Python 3 bindings for Linux SMBus access through i2c-dev   


or

Code: Select all

$ sudo apt-get install python3-smbus
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.       
Statusinformationen werden eingelesen.... Fertig
python3-smbus ist schon die neueste Version.
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.

User avatar
joan
Posts: 14470
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: python3-smbus

Sat Oct 03, 2015 11:44 am

I get the same error after installing python3-smbus.

It seems to be a Raspbian extension as the python3-smbus package is not present in my Debian jessie distribution.

I get plain files smbus-1.1.egg-info and smbus.cpython-32mu.so in /usr/lib/python3/dist-packages

Perhaps raise a Raspbian issue?

speendo
Posts: 13
Joined: Fri Sep 18, 2015 9:19 am

Re: python3-smbus

Sat Oct 03, 2015 12:07 pm

Thank you for checking!

I'm glad it's not just me ;-)

Where can I raise such an issue? At Github?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sat Oct 03, 2015 12:07 pm

Thanks, I'll take a look.

speendo
Posts: 13
Joined: Fri Sep 18, 2015 9:19 am

Re: python3-smbus

Sat Oct 03, 2015 12:09 pm

Wow!

That's what I call great service!

Thank you!

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: python3-smbus

Sat Oct 03, 2015 12:23 pm

In the meantime, it may be worth it install it via pip:

Code: Select all

sudo pip install smbus
sudo pip3 install smbus
There are 10 types of people: those who understand binary and those who don't.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sat Oct 03, 2015 12:28 pm

Looks like the package needs to be rebuilt.... *grumble*

Code: Select all

[email protected] ~ $ cp /usr/lib/python3/dist-packages/smbus.cpython-32mu.so ./
[email protected] ~ $ ./test.py 
Traceback (most recent call last):
  File "./test.py", line 2, in <module>
    from smbus import SMBus
ImportError: No module named 'smbus'
[email protected] ~ $ mv smbus.cpython-32mu.so smbus.so 
[email protected] ~ $ ./test.py
[email protected] ~ $

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sat Oct 03, 2015 12:42 pm

Try now:

Code: Select all

sudo apt-get update
sudo apt-get install -y python3-smbus

User avatar
joan
Posts: 14470
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: python3-smbus

Sat Oct 03, 2015 1:26 pm

That didn't work for me (even with --reinstall).

It seems to be ok if I manually copy smbus.cpython-32mu.so to smbus.so in usr/lib/python3/dist-packages.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sat Oct 03, 2015 1:43 pm

Joan, could you please post the output of 'apt-cache policy python3-smbus' ?

There shouldn't be a smbus.cpython-32mu.so now.

Code: Select all

[email protected] ~ $ apt-file list python3-smbus
python3-smbus: /usr/lib/python3/dist-packages/smbus-1.1.egg-info
python3-smbus: /usr/lib/python3/dist-packages/smbus.cpython-34m-arm-linux-gnueabihf.so
python3-smbus: /usr/share/doc/python3-smbus/changelog.Debian.gz
python3-smbus: /usr/share/doc/python3-smbus/changelog.gz
python3-smbus: /usr/share/doc/python3-smbus/copyright
[email protected] ~ $

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sat Oct 03, 2015 1:51 pm

Looks like your raspi.list is still using pointing to wheezy.
viewtopic.php?f=66&t=121880

User avatar
joan
Posts: 14470
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: python3-smbus

Sat Oct 03, 2015 2:06 pm

Code: Select all

harry ~ $ apt-cache policy python3-smbus
python3-smbus:
  Installed: 3.1.1+svn-1
  Candidate: 3.1.1+svn-1
  Version table:
 *** 3.1.1+svn-1 0
        500 http://archive.raspberrypi.org/debian/ wheezy/main armhf Packages
        100 /var/lib/dpkg/status
harry ~ $
I changed the /etc/apt/sources.list.d/raspi.list from wheezy to jessie and it seems to be ok now.

speendo
Posts: 13
Joined: Fri Sep 18, 2015 9:19 am

Re: python3-smbus

Sun Oct 04, 2015 12:18 am

I can confirm, that it works now!

Thank you! You are awesome!

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: python3-smbus

Sun Oct 04, 2015 12:54 am

Thank you for reporting and helping fix a problem.

RubePi
Posts: 14
Joined: Fri Apr 01, 2016 4:51 am
Location: Florida

Re: python3-smbus

Fri Apr 01, 2016 4:59 am

Thank you soooo much ShiftPlusOne and you others for bringing this up. I've been banging my head on this for weeks.
Now it works. I'm a nubie @Pi and python, and need i2c for my project. -- thanx agn!
p.s. this is what got me to register - something I don't often do.)
-- Jeff

njonas
Posts: 5
Joined: Wed Oct 08, 2014 3:41 am

Re: python3-smbus

Thu Jun 01, 2017 5:37 pm

I went through all these steps and I have the same issue still, on Python v3.6 and Jesse.

Code: Select all

[email protected]:~/dev/cl-ringo/rpi-camera $ python3
Python 3.6.1 (default, May 31 2017, 11:45:51)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'smbus'
>>> exit()

Code: Select all

$ apt-cache policy python3-smbus
python3-smbus:
  Installed: 3.1.1+svn-2
  Candidate: 3.1.1+svn-2
  Version table:
 *** 3.1.1+svn-2 0
        500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
        100 /var/lib/dpkg/status

Code: Select all

$ uname -a
Linux raspberrypi 4.9.24+ #993 Wed Apr 26 17:56:54 BST 2017 armv6l GNU/Linux
Has anyone else experienced this? Any ideas on how to fix this?

evil_homer
Posts: 1
Joined: Fri Jul 21, 2017 11:03 am

Re: python3-smbus

Fri Jul 21, 2017 11:07 am

Hi

Looks like package smbus is missing but there is replacement: https://pypi.python.org/pypi/smbus2/

Code: Select all

pip install smbus2
In Python code:

Code: Select all

import smbus2 as smbus

bus = smbus.SMBus(1)

User avatar
bensimmo
Posts: 4187
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: python3-smbus

Fri Jul 21, 2017 11:16 am

evil_homer wrote:Hi

Looks like package smbus is missing but there is replacement: https://pypi.python.org/pypi/smbus2/

Code: Select all

pip install smbus2
In Python code:

Code: Select all

import smbus2 as smbus

bus = smbus.SMBus(1)
I used to use that, but the one in raspbian works with python3 so I switched back.
Though Python3.6 is not part of a normal raspbian.

neokeitaro
Posts: 4
Joined: Mon Aug 07, 2017 1:35 pm

Re: python3-smbus

Sat Mar 31, 2018 11:58 am

Using raspbian stretch I still have this issue, anyone has an idea how to fix it?

Return to “Python”