image module does not run on iPython3

Asked

Viewed 226 times

1

I’m still a beginner in the world of programming, and I recently came across a problem that is still unsolved.

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 how to work with image processing. As the book is interactive, it offers its own platform for writing and running the lines of code, Activecode. The problem starts when in the book development tool, the "image" module is present and working, but in version 3 of the python I use, no.

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

import image

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

The program should return me 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 get to 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 didn’t work. Apparently they’re different things.

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

Follow the link from the site for you to take a look: How To Think Like a Computer Scientist

  • usually the library image is not installed by default in python, please install the library Pillow

  • Already tried using import Image ?

  • Yes, and the error persists. mportError Traceback (Most recent call last) <ipython-input-3-e90509fea2a2> in <module>() -----> 1 import Image 2 3 p = image.Pixel(45,76,200) 4 print(p.getRed()) Importing: No module named 'Image''

  • According to the developers website, to install Pillow, I need to uninstall PIL. as I uninstall the PIL library?

  • Using these commands: To uninstall: Pip Uninstall PIL

  • Try to uninstall Pil and install Pillow

  • just uninstall PIL, install Pillow and restart the computer. the error continues.

  • even with Pillow installed, the notebook ipython3 does not run this module.

Show 3 more comments

1 answer

0


According to the documentation Pillow, you will need to uninstall the PIL:

Pillow and PIL cannot co-exist in the same Environment. Before Stalling Pillow, Please Uninstall PIL.

Soon, uninstall PIL and install Pillow:

pip uninstall PIL
pip install Pillow

To use the 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)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.