From: wadi wadi on
Hi,

I am trying to run a python script and got this error.

>>import _md5
>>ImportError: No module named _md5

Googling the problem suggested that I install the 'py25-hashlib'.

the following does not work for me 'sudo port install py25-hashlib' ,
trying to install MacPorts raised many problems.

My question is: any idea on how to install it using yum?
I am running python 2.6.2 on a centos machine.

Many thanks for your help.
From: Diez B. Roggisch on
Hi,

please don't post this to comp.lang.python *and* the python mailinglist.
Both are synchronized, so your post shows up twice on both.

> I am trying to run a python script and got this error.
>
>>>import _md5
>>>ImportError: No module named _md5

I've never seen this import. Normally, it should be

import md5

So you might try to alter the import statement to

import md5 as _md5

and see if things work.

It might be of course that the author of your script provided a home-grown
implementation of md5 which has a different interface, and called this _md5
to prevent name-clashes. Then you need to modify your whole script to make
it work.

>
> Googling the problem suggested that I install the 'py25-hashlib'.
>
> the following does not work for me 'sudo port install py25-hashlib' ,
> trying to install MacPorts raised many problems.
>
> My question is: any idea on how to install it using yum?
> I am running python 2.6.2 on a centos machine.

I don't understand this - you are talking about ports which is a Mac-thing,
but run on centos?

However that may be, this *should* be part of core python anyway. If not,
you might look in yum for some python-dependency-packages, no idea how to
do that though (debian user here)

Diez
From: wadi wadi on
I can't alter the import statement as the error log is pointing to one
of the installed python files 'hashlib.py'

/python/2.6.2/lib/python2.6/hashlib.py

and I don't have the right permissions to alter the python installation.
Any idea?

On 10/29/09, Diez B. Roggisch <deets(a)nospam.web.de> wrote:
> Hi,
>
> please don't post this to comp.lang.python *and* the python mailinglist.
> Both are synchronized, so your post shows up twice on both.
>
>> I am trying to run a python script and got this error.
>>
>>>>import _md5
>>>>ImportError: No module named _md5
>
> I've never seen this import. Normally, it should be
>
> import md5
>
> So you might try to alter the import statement to
>
> import md5 as _md5
>
> and see if things work.
>
> It might be of course that the author of your script provided a home-grown
> implementation of md5 which has a different interface, and called this _md5
> to prevent name-clashes. Then you need to modify your whole script to make
> it work.
>
>>
>> Googling the problem suggested that I install the 'py25-hashlib'.
>>
>> the following does not work for me 'sudo port install py25-hashlib' ,
>> trying to install MacPorts raised many problems.
>>
>> My question is: any idea on how to install it using yum?
>> I am running python 2.6.2 on a centos machine.
>
> I don't understand this - you are talking about ports which is a Mac-thing,
> but run on centos?
>
> However that may be, this *should* be part of core python anyway. If not,
> you might look in yum for some python-dependency-packages, no idea how to
> do that though (debian user here)
>
> Diez
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
Wadienil.
From: Falcolas on
On Oct 29, 9:13 am, user7304 <wadie...(a)gmail.com> wrote:
> Hi,
>
> I am trying to run a python script and got this error.
>
> >>import _md5
> >>ImportError: No module named _md5
>
> Googling the problem suggested that I install the 'py25-hashlib'.
>
> the following does not work for me 'sudo port install py25-hashlib' ,
> trying to install MacPorts raised many problems.
>
> My question is: any idea on how to install it using yum?
> I am running python 2.6.2 on a centos machine.
>
> Many thanks for your help.

Try using hashlib.md5. From the docs:

>>> import hashlib
>>> m = hashlib.md5()
>>> m.update("Nobody inspects")
>>> m.update(" the spammish repetition")
>>> m.digest()
'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'

http://www.python.org/doc/2.5.2/lib/module-hashlib.html

Garrick
From: Diez B. Roggisch on
wadi wadi wrote:

> I can't alter the import statement as the error log is pointing to one
> of the installed python files 'hashlib.py'
>
> /python/2.6.2/lib/python2.6/hashlib.py
>
> and I don't have the right permissions to alter the python installation.
> Any idea?

Which is something different from what you communicated. I'd say your python
installation is botched, given the proprietary path I'd say whoever build
it locally should start from scratch.

Diez