Module 'image' does not run on iPython3

1

I'm still a beginner in the programming world, and recently I came across a problem that still has no solution.

I'm using an interactive online book to learn python (How to think like a computer scientist). In one of the chapters, the book teaches you how to work with image processing. Because the book is interactive, it offers its own platform for writing and routing code lines, ActiveCode. The problem starts when in the book development tool, the "image" module is present and working, but in version 3 of python that I use, no.

The version the book works is the same as the one I work on. I use the iPython3 notebook tool running in Firefox to program. When I run a simple program like:

import image

p = image.Pixel(45, 76, 200)
print(p.getRed())

The program should return the value "45", however an error message is displayed:

ImportError                               Traceback (most recent call last)
<ipython-input-7-83aeecd92382> in <module>()
----> 1 import image
  2 
  3 p = image.Pixel(45,76,200)
  4 print(p.getRed())

ImportError: No module named 'image'

Anyway, how do I solve this problem, and can I run this module on my computer?

I read in some places people talking to use the pil library with the command from PIL import Image , but it did not work. Apparently they are different things.

System Specification: Elementary OS 0.3.2 Freya (64-bit) Built on Ubuntu 14.04 Lenovo Y430 notebook

Follow the site link for a take a look at: How To Think Like a Computer Scientist

    
asked by anonymous 17.04.2016 / 01:11

1 answer

0

According to the Pillow documentation you will need to uninstall the PIL: / p>

  

Pillow and PIL can not co-exist in the same environment. Before installing Pillow, please uninstall PIL.

Then uninstall PIL and install Pillow:

pip uninstall PIL
pip install Pillow

To use Pillow:

''' Pegar o red do RGB de um pixel da imagem '''
from PIL import Image

im = Image.open('yourimage.jpg')
im = im.convert('RGB')
r, g, b = im.getpixel((1, 1))
print(r)
    
20.01.2017 / 13:06