On 18/02/2015, at 11:31 PM, [email protected] wrote:

> I recent migrated to a new apache server and when i am trying to run my wsgi 
> project i am getting the below error. 
> 
> I manage to track down the problem, but i can not find how to fix it... 
> 
> The problem is in the 
> /opt/webtier/python_64/lib/python2.6/site-packages/django/utils/hashcompat.py,
>  it tries to import hashlib and it fails. Since there is a try catch block in 
> the hashcompat.py it then tries to import md5 which is deprecated .... 
> 
> 
> 
> [Wed Feb 18 13:12:21 2015] [error] <mod_wsgi.Log object at 0x1007f6870>
> [Wed Feb 18 13:12:22 2015] [error]  | wgtproxy | __init__ |
> [Wed Feb 18 13:12:22 2015] [error] | wgtproxy settings |
> [Wed Feb 18 13:12:22 2015] [error] 
> /opt/webtier/python_64/lib/python2.6/site-packages/django/utils/hashcompat.py:15:
>  DeprecationWarning: the md5 module is deprecated; use hashlib instead
> [Wed Feb 18 13:12:22 2015] [error]   import md5
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx] mod_wsgi (pid=15944): 
> Exception occurred processing WSGI script 
> '/opt/wgt_proxy/wgtproxyProj/wgtproxy/apache/django.wsgi'.
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx] Traceback (most 
> recent call last):
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx]   File 
> "/opt/webtier/python_64/lib/python2.6/site-packages/django/core/handlers/wsgi.py",
>  line 230, in __call__
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx]     
> self.load_middleware()
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx]   File 
> "/opt/webtier/python_64/lib/python2.6/site-packages/django/core/handlers/base.py",
>  line 42, in load_middleware
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx]     raise 
> exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % 
> (mw_module, e))
> [Wed Feb 18 13:12:22 2015] [error] [client xx.xx.xx.xx] ImproperlyConfigured: 
> Error importing middleware django.middleware.common: "No module named _md5"
> [Wed Feb 18 13:12:22 2015] [error] [client xx.x.x.xx] Request Failed for : 
> /wgtproxy, Resp Code : [500]
> 
> 
> 
> I did a test wsgi script that the only thing is to print "Hello word" but at 
> the beginning i am also importing hashlib in order to verify that the hashlib 
> is the problem :
> 
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx] mod_wsgi (pid=15943): 
> Exception occurred processing WSGI script 
> '/opt/wgt_proxy/wgtproxyProj/wgtproxy/apache/test.wsgi'.
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx] Traceback (most 
> recent call last):
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]   File 
> "/opt/wgt_proxy/wgtproxyProj/wgtproxy/apache/test.wsgi", line 6, in <module>
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]     import hashlib
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]   File 
> "/opt/webtier/python_64/lib/python2.6/hashlib.py", line 136, in <module>
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]     md5 = 
> __get_builtin_constructor('md5')
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]   File 
> "/opt/webtier/python_64/lib/python2.6/hashlib.py", line 63, in 
> __get_builtin_constructor
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx]     import _md5
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx] ImportError: No 
> module named _md5
> [Wed Feb 18 14:16:32 2015] [error] [client xx.xx.xx.xx] Request Failed for : 
> /test, Resp Code : [500]
> 
> 
> Αccording to 
> https://code.google.com/p/modwsgi/wiki/ApplicationIssues#SSL_Shared_Library_Conflicts
>  it seems that when it tries to import hashlin it can not, the exception is 
> masked and tries to import _md5 which of course it does not exist ... 
> 
> The strange thing is that i can import hashlib without errors or exceptions 
> from python ... the issue is when apache+mod_wsgi tries to do it it fails! 
> 
> I did also did the " ldd  /bin/httpd " command but my apache is not 
> referencing any libssl.so library!!! 
> 
> Has anybody come across this issue ??? Can someone help??? 

Find the installed mod_wsgi.so file mod_wsgi in your Apache installation.

Run on it:

    ldd mod_wsgi.so

What it looks like is that mod_wsgi is compiled against the system Python 
installation, or at least at runtime is loading the system Python library. You 
though appear to be trying to force it to use an alternate Python runtime 
installation under /opt.

If it is picking up the wrong Python shared library, these sorts of problems 
can arise.

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to