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

Recommended Answers

All 4 Replies

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

import hashlib
print(hashlib)

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'>

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.