mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Error when trying examples with Python2

Sun Aug 30, 2015 4:19 pm

I've installed SenseHAT using
wget -O - http://www.raspberrypi.org/files/astro- ... install.sh --no-check-certificate | bash

When I run colour_cycle or rainbow.py using

Code: Select all

sudo python colour_cycle.py
I get

Code: Select all

self._pressure = RTIMU.RTPressure(self._imu_settings)
AttributeError: 'module' object has no attribute 'RTPressure
but error disappears when using

Code: Select all

sudo python3 colour_cycle.py
Any ideas as to what's happening?

Matthew

User avatar
B.Goode
Posts: 8024
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Error when trying examples with Python2

Sun Aug 30, 2015 5:05 pm

I can't find any specific evidence at http://pythonhosted.org/sense-hat/, but I think the chances are that the module you have downloaded and installed is designed to support and be compatible with Python3 scripts. So it may be working as intended.

(For the purposes of using imported modules and libraries, the only thing that python and python3 have in common is the first 6 characters of their names: in terms of implementation they are best regarded as 2 completely different languages.)

I believe the general policy of the Raspberry Pi Foundation is that new materials should be created using python3.

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Sun Aug 30, 2015 9:26 pm

Before I look into this any further I'd just like to know if others get the same problem or is it just somehting up with my installation

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

Re: Error when trying examples with Python2

Mon Aug 31, 2015 4:30 am

Either python2 or python3 would work.

That install script is deprecated and I don't know what the best way to undo what it has done is. The correct install instructions are on the pythonhosted page.

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Mon Aug 31, 2015 6:45 am

Thanks for info
Could you get someone to pass that info onto the Swag store to get them to change their instructions
http://swag.raspberrypi.org/collections ... -sense-hat

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Mon Aug 31, 2015 7:30 am

I don't know what the best way to undo what it has done is.
mm - it does seem a bit tricky

I tried

Code: Select all

sudo apt-get purge sense-hat 
followed by

Code: Select all

sudo apt-get autoremove
which accoring to screen info seemed to remvoe everything (inc RTIMU libs) but when I reinstalled sense-hat - same error message :(

I then tried manual deleting any ref to RTIMU files from /usr/lib/python2.7/dist-packages and then doing a purge and install but still same problem :(

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

Re: Error when trying examples with Python2

Mon Aug 31, 2015 7:47 am

Actually, I take that back. The script has been updated to do pretty much the same thing as what the instructions elsewhere say.

I'll look into it. Thanks

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 8:16 am

I am having trouble reproducing this problem. Works as expected...

Could you please provide the the output of 'pip freeze' and' pip-3.2 freeze'?

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Tue Sep 01, 2015 11:17 am

Code: Select all

pip freeze
Warning: cannot find svn location for distribute==0.6.24dev-r0
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
PIL==1.1.7
Pyste==0.9.10
RPi.GPIO==0.5.11
RTIMULib==1.0
WebIOPi==0.7.0
Werkzeug==0.9.6
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
certifi==14.05.14
## FIXME: could not find svn URL in dependency_links for this package:
distribute==0.6.24dev-r0
itsdangerous==0.24
mcpi==0.1.1
numpy==1.6.2
oauthlib==0.7.2
picamera==1.10
pifacecommon==4.1.2
pifacedigitalio==3.0.4
pygame==1.9.1release
pygobject==3.8.2
requests==2.5.0
requests-oauthlib==0.4.2
rpi-ws281x==1.1.0
scratchpy==0.1.0
sense-hat==2.1.0
smbus==1.1
spidev==2.0
tornado==4.0.2
twython==3.2.0
unicornhat==1.0.2
ws2812==1.0.0
wsgiref==0.1.2
and

Code: Select all

pip-3.2 freeze
Pillow==2.9.0
RPi.GPIO==0.5.11
RTIMULib==7.2.1
WebIOPi==0.7.0
## FIXME: could not find svn URL in dependency_links for this package:
distribute==0.6.24dev-r0
mcpi==0.1.1
numpy==1.6.2
pifacecommon==4.1.2
pifacedigitalio==3.0.4
sense-hat==2.1.0
unicornhat==1.0.2
ws2812==1.0.0
wsgiref==0.1.2
Warning: cannot find svn location for distribute==0.6.24dev-r0

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 11:47 am

Will need to get one of the python-ey people to take a look at it.

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 11:49 am

One thing that jumps out is
RTIMULib==1.0 vs
RTIMULib==7.2.1

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 11:53 am

Have you played around with the sense-hat prior to the launch? I am thinking you have an old version of RTIMULib which didn't have pressure sensor support on your system which is overriding the one provided by apt.

Edit: what does this say?

Code: Select all

sudo find /usr -name "*RTIMU*.so"

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Tue Sep 01, 2015 2:52 pm

I have tried out other gyro/accel boards in the past but first time with SenseHAT

Code: Select all

sudo find /usr -name "*RTIMU*.so"
/usr/local/lib/python2.7/dist-packages/RTIMU.so
/usr/lib/python3/dist-packages/RTIMU.cpython-32mu.so
/usr/lib/libRTIMULib.so
/usr/lib/python2.7/dist-packages/RTIMU.so

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 2:54 pm

I think it's /usr/local/lib/python2.7/dist-packages/RTIMU.so that's causing you problems.

mattmiller
Posts: 2079
Joined: Thu Feb 05, 2015 11:25 pm

Re: Error when trying examples with Python2

Tue Sep 01, 2015 3:16 pm

I've removed these two files

Code: Select all

 /usr/local/lib/python2.7/dist-packages/RTIMU.so 
 /usr/local/lib/python2.7/dist-packages/RTIMULib-1.0.egg-info
and I seem to up and running :)

Thanks very much for your help :)

Matthew

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

Re: Error when trying examples with Python2

Tue Sep 01, 2015 3:20 pm

No problem

Return to “Astro Pi”