wagtail / Willow

A wrapper that combines the functionality of multiple Python image libraries into one API
https://willow.wagtail.org/
BSD 3-Clause "New" or "Revised" License
274 stars 53 forks source link

AttributeError: 'PNGImageFile' object has no attribute 'detect_faces' #42

Closed mjdavies closed 8 years ago

mjdavies commented 8 years ago

Afternoon all

I'm pretty sure this isn't a problem with willow, but thought I'd ask in here to see if anyone can see my mistake.

We're getting an error trying to upload images.

Server Error Report this error to your webmaster with the following information: Internal Server Error - 500

AttributeError: 'PNGImageFile' object has no attribute 'detect_faces'

I got the same for jpegs as well.

It's working locally in my docker setup, and I can't seem to spot the difference in the pip list output, they seem the same.

Anyone got any ideas?

notworking.txt working.txt

kaedroho commented 8 years ago

Hey @mjdavies

What version Python are you using?

Could you run the following in a Django shell on the environment that doesn't work, and paste the output here:

from willow.registry import registry
registry._registered_image_classes
registry._unavailable_image_classes
registry._registered_operations
mjdavies commented 8 years ago

Hi Kaedroho

Here's that output. No module named cv jumps out a bit!!

output.txt

kaedroho commented 8 years ago

Thanks @mjdavies!

Yep, it looks like that may be the issue. Installing OpenCV can be a little tricky as it isn't pip-installable. You can find docs for installing it in Wagtail though: http://docs.wagtail.io/en/v1.5.2/advanced_topics/images/feature_detection.html#setup

It looks like there's a bug in Willow's error handling as it should've raised that ImportError('No module named cv',) error at the point you were accessing the detect_faces method. Which version of Python are you using?

mjdavies commented 8 years ago

Hi Kaedroho

Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2

I've just built a docker image for our app installing everything with pip and that has worked, which is a bit nuts!!

mjdavies commented 8 years ago

ok. moving on

I've uninstalled python-opencv, then reinstalled it.

I'm uploading the output of those commands again Kaedroho, ouput2.txt as I'm still getting the same error as before, but cv is present now.

output2.txt

mjdavies commented 8 years ago

Hello everyone, anyone got any ideas about this?