Using the Explorer Hat Pro in Python3


#1

I have a feeling that this is probably something simple, but I have just followed the Explorer Hat install instructions from GitHub on a fresh install of Raspbian and I am having some issues using it with Python3.

I have installed Python-smbus, but if I try importing the Explorer Hat library in Python3 it tells me that that it isn’t installed.

Python 2 works fine. What am I missing?


#2

Ah, looks like i need to do some Python version checking and tweak the advice accordingly!

For Python 3 it should say:

Install with: sudo apt-get install python3-smbus

#3

Ah damn, I knew it was going to be something simple! Slightly embarrassing…

Thanks for your help!


#4

Hmm I’ve follow this suggestion to the letter & installed with: sudo apt-get install python3-smbus.
However it doesn’t do a thing for me, the problem still persists with my Explorer HAT Pro, in as much as I still get the same warning as Dan doe’s, “Python-smbus isn’t installed” when using Python 3.

For the record I’m using the latest version of Raspbian Noobs: Version:1.4.2, Release date:2015-09-24 - Any suggestions would be gratefully received?

Personally IMO the Git could do with a re-write to make it a little easier for youngster’s & newbies to follow, with clearer instructions on how to install the examples library & instructions on the basic usage of the HAT with perhaps examples including a picture or two, showing something basic like lighting an led or connecting a motor to the to the hat.

If you were a youngster who’d just received this as a present or used their pocket money to purchase, I think you’d struggle to use it with it’s current documentation. Wading through support forums isn’t something you have should do for a retail item.

Cheers

Mark


#5

It looks like you’ve run into a bug with the python3-smbus package on Jessie that was found and fixed a few days ago ( see this thread: https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=122260&p=823965 ).

You should be able to get a non-broken version installed now using:

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

I’ve made some changes to the library to give better instructions in the case of a missing smbus, and I’ll make sure the easy-installer is updated to install for both Python 2 and 3 automagically- I think it’s a little outdated.

I’ll look over the Git page, too, I’ve been slowly going through our old libraries and making some code quality fixes and other tweaks so they don’t succumb to bit-rot, making the documentation/installers better would be a logical next step although I’d favour a much more visual guide on our learning portal.