Scroll phat : ImportError: No module named 'scrollphat'


#1

Good Afternoon,

I’m running the latest Google AIY image aiyprojects-2018-04-13 .

Both python2 and python3 are installed.

The latest Pimoroni dashboard is also installed along with the latest libraries.

However when I run: python3 test-all.py I get:

Traceback (most recent call last):
File “test-all.py”, line 7, in
import scrollphat
ImportError: No module named ‘scrollphat’

Running python test-all.py gets me:

Traceback (most recent call last):
File “test-all.py”, line 7, in
import scrollphat
File “/usr/lib/python2.7/dist-packages/scrollphat/init.py”, line 20, in
controller = IS31FL3730(smbus, font)
File “/usr/lib/python2.7/dist-packages/scrollphat/IS31FL3730.py”, line 17, in init
self.bus = self.bus.SMBus(1)
IOError: [Errno 2] No such file or directory

Anyone got any clues.

Oh, I tried to clone the repo also, to the same end.

Cheers,

Simon.


#2

Looks like you don’t have i2c enabled, and the Python3 module for Scroll pHAT isn’t installed;

sudo apt install python3-scrollphat

Then enable i2c in:

sudo raspi-config

#3

Thanks for the quick reply.

All of that has been done, and I get the same response:

pi@HAL9000:~ $ sudo apt install python3-scrollphat

Reading package lists… Done
Building dependency tree
Reading state information… Done
python3-scrollphat is already the newest version (0.0.7).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ python3 test-all.py

Traceback (most recent call last):
File “test-all.py”, line 7, in
import scrollphat
ImportError: No module named ‘scrollphat’

Oddly, it is not throwing an error at the:

import math
import sys
import time

Any ideas?


#4

Just checked the ‘PiGlow’ scripts.

Same deal:

pi@HAL9000:~/Pimoroni/piglow/examples $ python3 bar.py
Traceback (most recent call last):
File “bar.py”, line 5, in
import piglow
ImportError: No module named ‘piglow’

Yet the python games work OK.


#5

What does python3 --version say?


#6

May also be worth checking:

python3 -c "import sys;print(sys.path)"

and

dpkg -L python3-scrollphat


#7

Here you go…

pi@HAL9000:~ $ python3 --version
Python 3.5.3

pi@HAL9000:~ $ python3 -c “import sys;print(sys.path)”
[’’, ‘/usr/lib/python35.zip’, ‘/usr/lib/python3.5’, ‘/usr/lib/python3.5/plat-arm-linux-gnueabihf’, ‘/usr/lib/python3.5/lib-dynload’, ‘/usr/local/lib/python3.5/dist-packages’, ‘/opt/aiy/projects-python/src’, ‘/usr/lib/python3/dist-packages’]

pi@HAL9000:~ $ dpkg -L python3-scrollphat
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python3-scrollphat
/usr/share/doc/python3-scrollphat/changelog.gz
/usr/share/doc/python3-scrollphat/copyright
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/scrollphat-0.0.7.egg-info
/usr/lib/python3/dist-packages/scrollphat-0.0.7.egg-info/top_level.txt
/usr/lib/python3/dist-packages/scrollphat-0.0.7.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/scrollphat-0.0.7.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/scrollphat
/usr/lib/python3/dist-packages/scrollphat/init.py
/usr/lib/python3/dist-packages/scrollphat/IS31FL3730.py
/usr/lib/python3/dist-packages/scrollphat/font.py

Do I need to add a path somewhere?


#8

These are pretty much identical to what I see on my local system. Python is the same version, and it has '/usr/lib/python3/dist-packages' in its path.

What happens if you:

python3 -c "import scrollphat"

#9

Same error unfortunately:

pi@HAL9000:~ $ python3 -c “import scrollphat”
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named ‘scrollphat’

This is a completely fresh install of the OS too, so no tinkering by myself.


#10

I wonder if the files are simply broken. Filesystem corruption or otherwise?

You could prod at them with cat /usr/lib/python3/dist-packages/scrollphat/__init__.py etc. but I suspect that might just be a waste of time.

This could be worth a try:

sudo apt remove --purge python3-scrollphat
sudo apt install python3-scrollphat

Edit: ^ just flipped the above two commands, I put them in reverse order :D


#11

Also noticed the above in your sys.path, might be worth checking if this directory exists since I’m not sure what Python will do if it doesn’t.


#12

So, I purged and reinstalled.

Getting a different set of errors now:

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ python3 test-all.py
Traceback (most recent call last):
File “test-all.py”, line 7, in
import scrollphat
File “/usr/lib/python3/dist-packages/scrollphat/init.py”, line 20, in
controller = IS31FL3730(smbus, font)
File “/usr/lib/python3/dist-packages/scrollphat/IS31FL3730.py”, line 17, in init
self.bus = self.bus.SMBus(1)
FileNotFoundError: [Errno 2] No such file or directory


#13

Ah, so it was corrupt.

Enable i2c as mentioned above: sudo raspi-config


#14

ooh. no, that directory doesn’t exist, it’s:

> /home/pi/AIY-projects-python/src

How do I change it?


#15

The i2c is enabled.

I’ve checked via both CLI and GUI.


#16

You can check if i2c is actually enabled by looking at:

ls /dev/i2c*
dmesg | grep i2c
lsmod | grep i2c
cat /boot/config.txt | grep i2c

You should see output like this:

pi@raspberrypi:~ $ ls /dev/i2c*
/dev/i2c-1

pi@raspberrypi:~ $ dmesg | grep i2c
[    2.685060] i2c /dev entries driver

pi@raspberrypi:~ $ lsmod | grep i2c
i2c_bcm2835            16384  0
i2c_dev                16384  0

pi@raspberrypi:~ $ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=on

There’s a good chance if that one package was corrupt that more could be wrong with your system, you should probably re-image it.


#17

Does this mean i2c is alive or not?

pi@HAL9000:~ $ ls /dev/i2c*
ls: cannot access ‘/dev/i2c*’: No such file or directory

pi@HAL9000:~ $ dmesg | grep i2c
[ 2.411193] i2c /dev entries driver

pi@HAL9000:~ $ lsmod | grep i2c
i2c_dev 6913 0

pi@HAL9000:~ $ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=on

I can go back to an older image if needed, but I never used any Hats with that, so don’t know if I’ll have similar issues.

Worth a try though.


#18

Looks like the i2c_bcm2835 module is missing there, which wont help. Possibly suffered the same fate as Scroll pHAT.

You may be able to recover with a kernel reinstall:

sudo apt update
sudo apt upgrade
sudo apt install --reinstall raspberrypi-bootloader raspberrypi-kernel

#19

OK, so that got the i2c interface running.

Now I’m getting smbus errors.

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ ls /dev/i2c*
/dev/i2c-1

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ dmesg | grep i2c
[ 2.468308] i2c /dev entries driver

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ lsmod | grep i2c
i2c_bcm2835 16384 0
i2c_bcm2708 16384 0
i2c_dev 16384 0

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=on

pi@HAL9000:~/Pimoroni/scroll-phat/examples $ python3 test-all.py
Traceback (most recent call last):
File “test-all.py”, line 7, in
import scrollphat
File “/usr/lib/python3/dist-packages/scrollphat/init.py”, line 20, in
controller = IS31FL3730(smbus, font)
File “/usr/lib/python3/dist-packages/scrollphat/IS31FL3730.py”, line 21, in init
self.set_mode(self.i2cConstants.MODE_5X11)
File “/usr/lib/python3/dist-packages/scrollphat/IS31FL3730.py”, line 62, in set_mode
self.bus.write_i2c_block_data(self.i2cConstants.I2C_ADDR, self.i2cConstants.CMD_SET_MODE, [self.i2cConstants.MODE_5X11])
OSError: [Errno 121] Remote I/O error

Think I’m going to revert to an older image, see how that goes.


#20

I did have an issue getting scrollphat up and running on the AIY image way back when it was first released. Not sure if it’s the same issue: https://github.com/pimoroni/scroll-phat/issues/73