thumbor: ImportError: No module named cv

Installed thumbor and opencv on ubuntu 14.04.

cv2.so and cv.py are present on the system, but if I run python:

>>> import cv
Traceback (most recent call last):   
  File "<stdin>", line 1, in <module>
  File "cv.py", line 1, in <module>
    from cv2.cv import *
ImportError: No module named cv
>>> import cv2
>>>

cv2 imports, but no cv. If I try to run thumbor, local_detector.py throws

thumbor /etc/thumbor.conf
Traceback (most recent call last):
  File "/usr/local/bin/thumbor", line 9, in <module>
    load_entry_point('thumbor==5.0.0rc2', 'console_scripts', 'thumbor')()
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/server.py", line 58, in main
    importer.import_modules()
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/importer.py", line 48, in import_modules
    self.import_item('DETECTORS', 'Detector', is_multiple=True)
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/importer.py", line 74, in import_item
    module = self.import_class('%s.%s' % (module_name, class_name))
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/importer.py", line 33, in import_class
    module = get_module and __import__(name) or __import__(module_name)
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/detectors/face_detector/__init__.py", line 11, in <module>
    from thumbor.detectors.local_detector import CascadeLoaderDetector
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/detectors/local_detector.py", line 16, in <module>
    import cv2.cv as cv
ImportError: No module named cv

I figure “ok, let’s import cv2 instead”, so I change ‘import cv’ to ‘import cv2’, but then I get these warnings:

thumbor /etc/thumbor.conf
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.brightness could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.colorize could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.contrast could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.rgb could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.round_corner could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.noise could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.watermark could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.equalize could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.fill could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.saturation could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.sharpen could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Module thumbor.filters.frame could not be imported.
2015-04-10 13:08:42 thumbor:WARNING Error importing bounding_box filter, trimming won't work

Which I’m ok with, because I’m not currently using the filters, but as soon as I go to load a page and with this server to get a thumbnail:

tornado.application:ERROR Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 812, in run
    yielded = self.gen.send(value)
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/transformer.py", line 166, in do_smart_detection
    detectors[0](self.context, index=0, detectors=detectors).detect(self.after_smart_detect)
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/detectors/face_detector/__init__.py", line 21, in __init__
    self.load_cascade_file(__file__, self.context.config.FACE_DETECTOR_CASCADE_FILE)
  File "/usr/local/lib/python2.7/dist-packages/thumbor-5.0.0rc2-py2.7.egg/thumbor/detectors/local_detector.py", line 30, in load_cascade_file
    self.__class__.cascade = cv.Load(cascade_file)
NameError: global name 'cv' is not defined

What am I doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

@hchaithanya what’s your actual setup? Mac, Linux? what packages did you install? Did you try pip install opencv-python ?

Great, @Savar, I try pip install opencv-python. It works perfect.