diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

sense hat

Sun Feb 07, 2016 10:55 am

I am trying to use sense hat
Using the work sheet 'Sense Hat Random Sparkles ' I have progressed as far as pressing F5
I then get message 'From PIL import Image # pillow
import Error :No module named PIL'

Can you help please
diabeg

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: sense hat

Sun Feb 07, 2016 10:58 am

Code: Select all

sudo apt-get install python3-pip
sudo pip3 install pillow
There are 10 types of people: those who understand binary and those who don't.

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Sun Feb 07, 2016 11:09 am

kusti8 wrote:

Code: Select all

sudo apt-get install python3-pip
sudo pip3 install pillow
Correct on Jessie.
But AFAIK it should already be installed on the Jessie image.

So it could be that OP is using Wheezy. In that case the second command should be

Code: Select all

sudo pip-3.2 install pillow
I would also run

Code: Select all

sudo apt-get update
before installing programs

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Sun Feb 07, 2016 11:51 am

Hello
I have followed suggestions but still get the same message
I do not know if I have Jessie but I think I have wheezy
Thanks for taking an interest
diabeg

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Sun Feb 07, 2016 12:04 pm

diabeg wrote:Hello
I have followed suggestions but still get the same message
Are you using python 2 or 3 to run your scripts?
IIRC they are set up for v3.

If you're using python 2 then the commands as mentioned above have to be changed.

If you are using python 3: did you get any error messages when you ran the install commands?
If so, please post them here.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Sun Feb 07, 2016 12:26 pm

Hello
I am using Python 3
I do not think I have had any other error message apart from the message in my original query
diabeg

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Sun Feb 07, 2016 12:46 pm

diabeg wrote:Hello
I am using Python 3
I do not think I have had any other error message apart from the message in my original query
diabeg
Then you should not get the error message.
If you're not sure try installing it again and check the messages carefuly.

And can you post the *full* error message of the import error? Normally you get a traceback consisting of more than 1 line.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Sun Feb 07, 2016 12:53 pm

Traceback (most recent call last):
File "/home/pi/sparkles.py", line 1, in <module>
from sense_hat import SenseHat
File "/usr/lib/python3/dist-packages/sense_hat/__init__.py", line 2, in <module>
from .sense_hat import SenseHat, SenseHat as AstroPi
File "/usr/lib/python3/dist-packages/sense_hat/sense_hat.py", line 14, in <module>
from PIL import Image # pillow
ImportError: No module named PIL
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Sun Feb 07, 2016 12:56 pm

Well, that means pillow is not (properly) installed.
You'll have to go back to the posts further up on how to get that fixed.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Sun Feb 07, 2016 12:59 pm

Thank you
I think you may have found the problem
My head is now full so I will have another attempt tomorrow
I will get there with the forums help
diabeg

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Tue Feb 09, 2016 10:40 am

DirkS wrote:Well, that means pillow is not (properly) installed.
You'll have to go back to the posts further up on how to get that fixed.
I am still trying to use Sense Hat
Can you help in installing Pillow correctly ?
Thank you
diabeg

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Tue Feb 09, 2016 11:00 am

First of all: can you check if you have a directory named 'PIL' in your home directory (/home/pi)
If so, then that will cause the problems you are seeing...

If not, then first make sure pip is installed:

Code: Select all

sudo apt-get update
sudo apt-get install python3-pip
After that's installed you can install pillow with

Code: Select all

sudo pip-3.2 install pillow
That should be all that's needed.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Tue Feb 09, 2016 11:36 am

DirkS wrote:First of all: can you check if you have a directory named 'PIL' in your home directory (/home/pi)
If so, then that will cause the problems you are seeing...

If not, then first make sure pip is installed:

Code: Select all

sudo apt-get update
sudo apt-get install python3-pip
After that's installed you can install pillow with

Code: Select all

sudo pip-3.2 install pillow
That should be all that's needed.
In directory tree listed under build is
Pillow and in Pillow is PIL
Under PIL is
Pillow.egg-info
Also PIP-egg-info
I have also installed again as suggested but I continue to get the error message as detailed earlier when trying to use Sense Hat

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Tue Feb 09, 2016 11:43 am

pi@raspberrypi ~ $ sudo apt-get update
Hit http://raspberrypi.collabora.com wheezy Release.gpg
Get:1 http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Hit http://raspberrypi.collabora.com wheezy Release
Get:2 http://mirrordirector.raspbian.org wheezy Release [14.4 kB]
Get:3 http://archive.raspberrypi.org wheezy Release.gpg [473 B]
Get:4 http://archive.raspberrypi.org wheezy Release [17.6 kB]
Hit http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Get:5 http://mirrordirector.raspbian.org wheezy/main armhf Packages [6,909 kB]
Get:6 http://archive.raspberrypi.org wheezy/main armhf Packages [136 kB]
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en_GB
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en
Ign http://archive.raspberrypi.org wheezy/main Translation-en_GB
Ign http://archive.raspberrypi.org wheezy/main Translation-en
Get:7 http://mirrordirector.raspbian.org wheezy/contrib armhf Packages [23.6 kB]
Get:8 http://mirrordirector.raspbian.org wheezy/non-free armhf Packages [49.3 kB]
Get:9 http://mirrordirector.raspbian.org wheezy/rpi armhf Packages [592 B]
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Fetched 7,152 kB in 42s (168 kB/s)
Reading package lists... Done
pi@raspberrypi ~ $ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi ~ $ sudo pip-3.2 install pillow
Downloading/unpacking pillow
Running setup.py egg_info for package pillow
Single threaded build, not installing mp_compile:1 processes

warning: no previously-included files found matching '.editorconfig'
Installing collected packages: pillow
Running setup.py install for pillow
Single threaded build, not installing mp_compile:1 processes

warning: no previously-included files found matching '.editorconfig'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/pi/build/pillow/setup.py", line 767, in <module>
zip_safe=not debug_build(),
File "/usr/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 53, in run
return _install.run(self)
File "/usr/lib/python3.2/distutils/command/install.py", line 607, in run
self.run_command('build')
File "/usr/lib/python3.2/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/usr/lib/python3.2/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib/python3.2/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/usr/lib/python3.2/distutils/command/build_ext.py", line 344, in run
self.build_extensions()
File "/home/pi/build/pillow/setup.py", line 516, in build_extensions
(f, f))
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting
Complete output from command /usr/bin/python3.2 -c "import setuptools;__file__='/home/pi/build/pillow/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-_kll9x-record/install-record.txt:
Single threaded build, not installing mp_compile:1 processes

running install

running build

running build_py

running egg_info

writing Pillow.egg-info/PKG-INFO

writing top-level names to Pillow.egg-info/top_level.txt

writing dependency_links to Pillow.egg-info/dependency_links.txt

warning: manifest_maker: standard file '-c' not found



reading manifest file 'Pillow.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

warning: no previously-included files found matching '.editorconfig'

writing manifest file 'Pillow.egg-info/SOURCES.txt'

running build_ext

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/home/pi/build/pillow/setup.py", line 767, in <module>

zip_safe=not debug_build(),

File "/usr/lib/python3.2/distutils/core.py", line 148, in setup

dist.run_commands()

File "/usr/lib/python3.2/distutils/dist.py", line 917, in run_commands

self.run_command(cmd)

File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command

cmd_obj.run()

File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 53, in run

return _install.run(self)

File "/usr/lib/python3.2/distutils/command/install.py", line 607, in run

self.run_command('build')

File "/usr/lib/python3.2/distutils/cmd.py", line 313, in run_command

self.distribution.run_command(command)

File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command

cmd_obj.run()

File "/usr/lib/python3.2/distutils/command/build.py", line 126, in run

self.run_command(cmd_name)

File "/usr/lib/python3.2/distutils/cmd.py", line 313, in run_command

self.distribution.run_command(command)

File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command

cmd_obj.run()

File "/usr/lib/python3.2/distutils/command/build_ext.py", line 344, in run

self.build_extensions()

File "/home/pi/build/pillow/setup.py", line 516, in build_extensions

(f, f))

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

----------------------------------------
Command /usr/bin/python3.2 -c "import setuptools;__file__='/home/pi/build/pillow/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-_kll9x-record/install-record.txt failed with error code 1 in /home/pi/build/pillow
Storing complete log in /root/.pip/pip.log
pi@raspberrypi ~ $

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Tue Feb 09, 2016 11:50 am

Installation of pillow failed because of a missing library.
Run

Code: Select all

sudo apt-get install libjpeg-dev
and then try to install pillow again.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 10:44 am

Hello
I must be getting a little closer to operating sense hat
This is my latest error

Traceback (most recent call last):
File "/home/pi/sparkles.py", line 14, in <module>
sense.set_pixel (x, y, r, g, b)
File "/usr/lib/python3/dist-packages/sense_hat/sense_hat.py", line 318, in set_pixel
raise ValueError(pixel_error)
ValueError: Pixel arguments must be given as (r, g, b) or r, g, b
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 1:11 pm

Looks as if you have an older version of the sense hat python module.
Can you post the output of

Code: Select all

apt-cache policy python-sense-hat
It shows available and installed version and would look something like this

Code: Select all

pi@raspi2b:~$ apt-cache policy python-sense-hat
python-sense-hat:
  Installed: 2.1.0-1
  Candidate: 2.1.0-1
  Version table:
 *** 2.1.0-1 0
        500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
        100 /var/lib/dpkg/status

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 2:25 pm

DirkS wrote:Looks as if you have an older version of the sense hat python module.
Can you post the output of

Code: Select all

apt-cache policy python-sense-hat
It shows available and installed version and would look something like this

Code: Select all

pi@raspi2b:~$ apt-cache policy python-sense-hat
python-sense-hat:
  Installed: 2.1.0-1
  Candidate: 2.1.0-1
  Version table:
 *** 2.1.0-1 0
        500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
        100 /var/lib/dpkg/status
pi@raspberrypi ~ $ apt-cache policy python-sence-hat
N: Unable to locate package python-sence-hat
pi@raspberrypi ~ $

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 3:00 pm

diabeg wrote:pi@raspberrypi ~ $ apt-cache policy python-sence-hat
N: Unable to locate package python-sence-hat
pi@raspberrypi ~ $
There's a typo in there; it's 'python-sense-hat'

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 3:07 pm

pi@raspberrypi ~ $ apt-cache policy python-sence-hat
N: Unable to locate package python-sence-hat
pi@raspberrypi ~ $ apt-cache policy'python-sense-hat'
E: Invalid operation policypython-sense-hat
pi@raspberrypi ~ $ apt-cache policy python-sense-hat
python-sense-hat:
Installed: 2.1.0-1~bpo8+1
Candidate: 2.1.0-1~bpo8+1
Version table:
*** 2.1.0-1~bpo8+1 0
500 http://archive.raspberrypi.org/debian/ wheezy/main armhf Packages
100 /var/lib/dpkg/status
pi@raspberrypi ~ $

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 3:27 pm

I'm pretty much stumped...

Just one thing I can think off: did you copy and paste code from the website?
This can introduce invisible characters that can have surprising effects.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 3:34 pm

DirkS wrote:I'm pretty much stumped...

Just one thing I can think off: did you copy and paste code from the website?
This can introduce invisible characters that can have surprising effects.
I did not copy and paste from web site
Sense Hat was given to me as a present in a box and I just fitted it into Pi
On the box it quotes 894-9310 made in UK
You have a lot of patience
Thank you
diabeg

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 4:04 pm

Just to make sure I did not miss anything: can you post your code here.
Make sure you put it in a block.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 4:11 pm

The only code I have from the box is
894-9310

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 4:16 pm

diabeg wrote:The only code I have from the box is
894-9310
I meant your python source code.

Return to “Astro Pi”