JohannesBuchner / imagehash

A Python Perceptual Image Hashing Module
BSD 2-Clause "Simplified" License
3.28k stars 331 forks source link

AttributeError: module 'ImageHash' has no attribute 'average_hash' #126

Closed KonstantinMastak closed 3 years ago

KonstantinMastak commented 3 years ago

I tried to install the library using:

pip install ImageHash

Then I try something like:

from PIL import Image import ImageHash

def main(): hash = ImageHash.average_hash(Image.open('D:\test.png')) print(hash)

if name == 'main': main()

The first problem was that Python 3.8 (Windows) doesn't find ImageHash library at all. I went to C:\Program Files (x86)\Python38-32\Lib\site-packages and see folder ImageHash-4.2.0.dist-info and separate file imagehash.py. However all other libraries in that folder also have a subflolder without version in their names, so I created folder C:\Program Files (x86)\Python38-32\Lib\site-packages\ImageHash and copied imagehash.py file there.

After that the error message changed. Now Python sees ImageHash library but shows this error:

AttributeError: module 'ImageHash' has no attribute 'average_hash'

Any ideas on how to solve it? Thanks for advance!

BTW, the whole folder C:\Program Files (x86)\Python38-32\ in in my PATH variables.

JohannesBuchner commented 3 years ago

The library is called imagehash, not ImageHash.

KonstantinMastak commented 3 years ago

Thank you very much! That solved my problem. I was not aware it is case sensitive.

вт, 5 янв. 2021 г. в 14:35, Johannes Buchner notifications@github.com:

The library is called imagehash, not ImageHash.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JohannesBuchner/imagehash/issues/126#issuecomment-754553090, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGF4DE54VAVXNR32URNYAOTSYLTNRANCNFSM4VTWJ6DQ .

-- С уважением, Константин Артемьев