Stefano58
Posts: 11
Joined: Tue Feb 03, 2015 11:37 am

SMbus

Fri Feb 13, 2015 9:24 am

In Raspbian, how can I install SMBUS for python 3.2.3?
It works in python 2.7.3.
Thanks in advance

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SMbus

Fri Feb 13, 2015 10:26 am

sudo apt-get install python{,3}-smbus
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Stefano58
Posts: 11
Joined: Tue Feb 03, 2015 11:37 am

Re: SMbus

Fri Feb 13, 2015 2:38 pm

Hi,
apt-get install python-smbus tell me "Unable to locate package ......"
apt-get install python3-smbus tell me "Unable to locate package ......"
apt-get install python.3-smbus tell me "Unable to locate package ......"
pip-3.2 install python-smbus tell me "No distributions at all found for python...."
pip-3.2 install python3-smbus tell me "No distributions at all found for python...."
pip-3.2 install python.3-smbus tell me "No distributions at all found for python...."


Sorry for personal message, how can I send the message on the forum?

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SMbus

Fri Feb 13, 2015 4:44 pm

You're going to have to build the code from source

Code: Select all

sudo -i
apt-get install libi2c-dev
cd /tmp
wget http://ftp.de.debian.org/debian/pool/main/i/i2c-tools/i2c-tools_3.1.0.orig.tar.bz2
tar xavf i2c-tools_3.1.0.orig.tar.bz2
cd i2c-tools-3.1.0/py-smbus
python3 setup.py install
exit
More details here: http://www.raspberrypi.org/forums/viewt ... 32&t=22348


"No personal messages" is just a line in my standard forum signature.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Stefano58
Posts: 11
Joined: Tue Feb 03, 2015 11:37 am

Re: SMbus

Fri Feb 13, 2015 6:16 pm

Hi,
when I write "python3 setup.py install", Raspberry (Raspbian) responde a lot of warnings and:
"error: command 'gcc' failed with exit status 1".
What's the problem now.
thanks

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SMbus

Fri Feb 13, 2015 7:32 pm

You'll need to report that to the package maintainer.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Stefano58
Posts: 11
Joined: Tue Feb 03, 2015 11:37 am

Re: SMbus

Sat Feb 14, 2015 7:48 pm

Hi, is it enough?
----------------------------------------------
root@raspberrypi:/tmp/i2c-tools-3.1.0/py-smbus# python3 setup.py install
running install
running build
running build_ext
building 'smbus' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -I/usr/include/python3.2mu -c smbusmodule.c -o build/temp.linux-armv6l-3.2/smbusmodule.o
smbusmodule.c: In function ‘SMBus_dealloc’:
smbusmodule.c:94:6: error: ‘SMBus’ has no member named ‘ob_type’
smbusmodule.c: In function ‘SMBus_list_to_data’:
smbusmodule.c:434:3: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
smbusmodule.c:438:3: warning: implicit declaration of function ‘PyInt_AS_LONG’ [-Wimplicit-function-declaration]
smbusmodule.c: At top level:
smbusmodule.c:637:2: warning: missing braces around initializer [-Wmissing-braces]
smbusmodule.c:637:2: warning: (near initialization for ‘SMBus_type.ob_base.ob_base’) [-Wmissing-braces]
smbusmodule.c:639:2: warning: initialization makes integer from pointer without a cast [enabled by default]
smbusmodule.c:639:2: warning: (near initialization for ‘SMBus_type.tp_basicsize’) [enabled by default]
smbusmodule.c:642:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:642:2: warning: (near initialization for ‘SMBus_type.tp_print’) [enabled by default]
smbusmodule.c:657:2: warning: initialization makes pointer from integer without a cast [enabled by default]
smbusmodule.c:657:2: warning: (near initialization for ‘SMBus_type.tp_doc’) [enabled by default]
smbusmodule.c:658:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:658:2: warning: (near initialization for ‘SMBus_type.tp_traverse’) [enabled by default]
smbusmodule.c:665:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:665:2: warning: (near initialization for ‘SMBus_type.tp_members’) [enabled by default]
smbusmodule.c:667:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:667:2: warning: (near initialization for ‘SMBus_type.tp_base’) [enabled by default]
smbusmodule.c:673:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:673:2: warning: (near initialization for ‘SMBus_type.tp_alloc’) [enabled by default]
smbusmodule.c:675:2: warning: initialization from incompatible pointer type [enabled by default]
smbusmodule.c:675:2: warning: (near initialization for ‘SMBus_type.tp_free’) [enabled by default]
smbusmodule.c: In function ‘initsmbus’:
smbusmodule.c:691:3: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
smbusmodule.c:693:2: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
smbusmodule.c:693:4: warning: assignment makes pointer from integer without a cast [enabled by default]
error: command 'gcc' failed with exit status 1
root@raspberrypi:/tmp/i2c-tools-3.1.0/py-smbus#
---------------------------------------------------------------------------------------

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SMbus

Sat Feb 14, 2015 7:55 pm

You need to send that to the package developer. It's not my code.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Stefano58
Posts: 11
Joined: Tue Feb 03, 2015 11:37 am

Re: SMbus

Mon Feb 16, 2015 2:57 pm

HI,
his is the correct procedure to install SMBus for python3
------------------------------------------
sudo -i
apt-get install libi2c-dev
cd /tmp
wget http://ftp.de.debian.org/debian/pool/ma ... ig.tar.bz2 # download Python 2 source
tar xavf i2c-tools_3.1.0.orig.tar.bz2
cd i2c-tools-3.1.0/py-smbus
mv smbusmodule.c smbusmodule.c.orig # backup
wget https://gist.githubusercontent.com/seba ... usmodule.c # download patched (Python 3) source
python3 setup.py build
python3 setup.py install
exit
----------------------------------

LearningPerson
Posts: 1
Joined: Wed May 13, 2015 3:33 pm

Re: SMbus

Wed May 13, 2015 3:48 pm

Dear Stefano58:
Thank you for your post, I followed this but got a error that looked like this:
fatal error: Python.h: No such file or directory compilation terminated.
The solution was to use:
sudo apt-get install python3-dev
I suspect you already did that before your post, but for a new person (me) with a new Raspberry PI (me again) that solves the compile problem.
The Raspberry Pi I'm using (Linux 3.18.7, Python 3.2.3, IDLE 3.2.3) will now run a program containing
import smbus

(I just got the compile and run, no info on functioning properly yet.)

Return to “Python”