0

Hello,

I'm trying to use md5 in python3 using the attached code

from  hashlib import md5 
password = 'pa$$w0rd'
h = hashlib.md5()

print(h.hexdigest())

put it gives me this error (cannot import name 'md5')

and when i try to import hashlib only it gives this error (module 'hashlib' has no attribute 'md5')

I searched everywhere but i cant find any solution to my case

2
Contributors
4
Replies
19
Views
10 Months
Discussion Span
Last Post by <HHH>
0

You may be shadowing the standard lib's hashlib module with another module with the same name. Try

import hashlib
print(hashlib)
0

it produces the below output but how this can help me

<module 'hashlib' from 'C:\Users\hohait\Desktop\hashlib.py'>
<module 'hashlib' from 'C:\Users\hohait\Desktop\hashlib.py'>

0

This file is not the file hashlib.py from the python's standard library. You could rename it (for example myhashlib.py). Make sure that there are no hashlib.pyc or hashlib.pyw in the Desktop folder

0

Thank you very much man i have spend 7 hours trying to figure out whats wrong
you really helped me thank you again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.