3

Hi I just got a Raspberry Pi, and I'm working on some very simple code here. What I'm trying to do is to capture an image and display it.

import PIL
import Image
import picamera
camera = picamera.PiCamera()
camera.capture("image.jpg")
im = Image.open("image.jpg")
im.show()

There was no error, but the image would not show up.

I checked the file, the picture was taken, so no problem on that part of the code.

Would really like some help, thanks!

0

1 Answer 1

2

Python is case-sensitive. You are importing Image so use it.

Change image to Image in im = image("image.jpg") It'll become:

from PIL import Image
import picamera
camera = picamera.PiCamera()
camera.capture("image.jpg")
im = Image.open("image.jpg")
im.show()
Sign up to request clarification or add additional context in comments.

11 Comments

I was about to edit the question when you answered! Much appreciated, I found this error and I changed it. Now is says: TypeError:'module' object is not callable
use PIL.Image or make proper import from PIL import Image
Now it has become: AttributeError: 'module' object has no attribute 'Image'
also you missed quotes here camera.capture(image.jpg), use camera.capture("image.jpg")
And if I use 'from PIL import Image' is becomes "NameError: name 'PIL' is not defined"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.