OpenCV imread hanging when called from a web request

前端 未结 2 1302
忘了有多久
忘了有多久 2020-12-08 22:30

This is probably one of the strangest errors that I have ever ran into when using OpenCV. There is a lot going on, so let me try to explain this to the best of my ability.

相关标签:
2条回答
  • 2020-12-08 23:00

    Wrong

    imagePath = os.path.dirname(__file__) + "/1.jpg"
    

    Right

    from os.path import abspath, join, dirname
    
    imagePath = abspath( join(dirname(__file__), "1.jpg") )
    
    0 讨论(0)
  • 2020-12-08 23:04

    I had a similar issue and found a fix -> just add to your apache configuration:

    WSGIScriptAlias application-group=%{GLOBAL}
    

    Apparently it happens when you have an extension module not designed to work in sub interpreter. The above forces it to run in main interpreter.

    Sources: django apache mod-wsgi hangs on importing a python module from .so file http://blog.rtwilson.com/how-to-fix-flask-wsgi-webapp-hanging-when-importing-a-module-such-as-numpy-or-matplotlib/

    0 讨论(0)
提交回复
热议问题