[uWSGI] uWSGI - No module named _md5 error when working with virtualenv

Michael Kang wxiluo at gmail.com
Mon Nov 15 09:40:27 CET 2010


It's very strange error:

/home/k4/Envs/k4/lib/python2.6/site-packages/django/utils/hashcompat.py:15:
DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
Traceback (most recent call last):
  File
"/home/k4/Envs/k4/lib/python2.6/site-packages/django/core/handlers/wsgi.py",
line 230, in __call__
    self.load_middleware()
  File
"/home/k4/Envs/k4/lib/python2.6/site-packages/django/core/handlers/base.py",
line 42, in load_middleware
    raise exceptions.ImproperlyConfigured, 'Error importing middleware %s:
"%s"' % (mw_module, e)
django.core.exceptions.ImproperlyConfigured: Error importing middleware
django.middleware.common: "No module named _md5"

In the hashcompat.py, there are just 9 lines:

try:

    import hashlib

    md5_constructor = hashlib.md5

    sha_constructor = hashlib.sha1

except ImportError:

    import md5

    md5_constructor = md5.new

    import sha
    sha_constructor = sha.new

But I can import hashlib successfully. The program should never run import
md5 and sha.


On Mon, Nov 15, 2010 at 11:53 AM, Michael Kang <wxiluo at gmail.com> wrote:

> Hi all,
>
> I get this error on uWSGI:
> django.core.exceptions.ImproperlyConfigured: Error importing middleware
> django.middleware.common: "No module named _md5"
>
> I got a DeprecationWarning when I import md5:
>
> Python 2.6.6 (r266:84292, Nov 11 2010, 11:59:08)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import md5
> __main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib
> instead
> >>> import _md5
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named _md5
> >>> import hashlib
> >>> import _hashlib
>
> I find a similar thread here - http://bit.ly/d5cpnY.
>
> I edited uwsgiconfig.py and set PYLIB_PATH to the path of the lib
> directory to $HOME/py26/lib for compiling it on CentOS 5.5. Maybe this is
> the problem.
>
> ldd uwsgi
>         libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003d92e00000)
>         libdl.so.2 => /lib64/libdl.so.2 (0x0000003d92600000)
>         libutil.so.1 => /lib64/libutil.so.1 (0x0000003da2800000)
>         libm.so.6 => /lib64/libm.so.6 (0x0000003d92a00000)
>         libpython2.6.so.1.0 => /home/k4/py26/lib/libpython2.6.so.1.0
> (0x00002b2d6c4cc000)
>         libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x0000003d9d200000)
>         libz.so.1 => /usr/lib64/libz.so.1 (0x0000003d93200000)
>         libc.so.6 => /lib64/libc.so.6 (0x0000003d92200000)
>         /lib64/ld-linux-x86-64.so.2 (0x0000003d91e00000)
>
> You can see the the libpython2.6.so is linked to
> $HOME/py26/lib/libpython2.6.so.1.0.
>
> Does anybody have the same problem?
>
> Michael Kang
>
> --
> Michael Kang(康上明学)
> There is a giant asleep within every man. When the giant awakens,miracles
> happen.
>
> Personal Blog: http://ufusion.org - United Fusion
>



-- 
Michael Kang(康上明学)
There is a giant asleep within every man. When the giant awakens,miracles
happen.

Personal Blog: http://ufusion.org - United Fusion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.unbit.it/pipermail/uwsgi/attachments/20101115/18424cbc/attachment.htm 


More information about the uWSGI mailing list