python3?

Forums:

Hi, am trying to get the Ultraborg working in the latest version of Webiopi, but getting a synthax errors on the print statements from UltraBorg.py when I run it.

I read on the forum that you provided a fixed file for the picoborgrev to a user from the downloads, do you perhaps have a working python3 lib for the UltraBorg too?

Really want to use your board with webiopi ;)

thx!

piborg's picture

No problem, the fix to the script is fairly simple so I have uploaded a version which should be WebIOPi and Python 3 compatible.

Like with the PicoBorg Reverse, there are two problems:

  • The old Python 2 style print statement is no longer correct
  • It will not be able to import smbus as it is only available for Python 2.X by default

The first problem is easy to fix, it simply requires a version using the correct print statements

cd ~/ultraborg
wget -O UltraBorg3.py http://piborg.org/downloads/ultraborg/UltraBorg3.py.txt

To use this version you will need to change the import statement to

import UltraBorg3 as UltraBorg

Then you can use it normally.

The second problem is a bit more tricky, what we can do is rebuild smbus for Python 3 by making some small changes to the source:

cd ~
sudo apt-get -y install python3-dev
wget http://ftp.de.debian.org/debian/pool/main/i/i2c-tools/i2c-tools_3.1.0.orig.tar.bz2
tar xf i2c-tools_3.1.0.orig.tar.bz2
cd i2c-tools-3.1.0/py-smbus
mv smbusmodule.c smbusmodule.c.orig
wget -O smbusmodule.c http://piborg.org/downloads/picoborgrev/smbusmodule.c.txt
wget http://lm-sensors.org/svn/lm-sensors/tags/V2-10-8/kernel/include/i2c-dev.h
python3 setup.py build
sudo python3 setup.py install

This should make the smbus module available to Python 3, and hopefully make everything work happily.

You only need to do the smbus module changes once, so if you have already done this for PicoBorg Reverse it can be skipped.

noxgenus's picture

Thanks so much piborg :) all working fine from webiopi now! Moving servo with html/js now, time to order some of those sensors and fill up the board :)

Hello everybody,

i tried the method to get the i2c-dev.h file. Unfortunately, the website is offline.
Is there another link, which I can try?

Thank you,
morpfl

piborg's picture

It looks like this is much easier now on recent copies of Raspbian:
http://www.linuxcircle.com/2015/05/03/how-to-install-smbus-i2c-module-fo...

You should only need to do the following to get the Python 3 smbus module:

sudo apt-get update
sudo apt-get -y install python3-smbus
Subscribe to Comments for "python3?"