imagehash icon indicating copy to clipboard operation
imagehash copied to clipboard

Continue even if scipy.fftpack is missing

Open runarbu opened this issue 10 years ago • 2 comments

Unfortunately so is scipy.fftpack unavailable on some systems. Mainly ActivePython on Windows.

However since scipy.fftpack is only used in the pHash function one could cache the error and still allow the user to use aHash and dHash. The attached code tries to import the scipy.fftpack module. If it is not available pHash will not work (pHash will fail on importing scipy.fftpack in the pHash function if called. This to show the user what import failed), but users can still use aHash and dHash.

runarbu avatar Sep 09 '14 12:09 runarbu

Glad you could solve your issue. However, scipy is still a dependency in setup.py.

On a stylistic note, "if (havefftpack == False):" can be replaced by "if not havefftpack:" in line 128.

JohannesBuchner avatar Sep 09 '14 12:09 JohannesBuchner

However, scipy is still a dependency in setup.py.

Yes, thought it was best to have it as a dependency so scipy gets installed if it is not already installed. This way it will work as before on most platforms. ActivePython also have scipy and scipy.fftpack but on some system scipy.fftpack will not work because the DLL file _fftpack.pyd fails to load. According to this thread ( http://stackoverflow.com/questions/13099276/64-bit-scipy-fftpack-for-windows ) the underlying problem is that a Intel's Math Kernel Library DLL is missing, but I was not able to make _fftpack.pyd load on my computer, even after adding the mention libmmd.dll file.

To sum it up: If scipy is a dependency scipy.fftpack will be installed correctly most if the time, just as before, but if you have a broken scipy.fftpack even after installing scipy my patch only disable pHash, not the whole module.

If you remove scipy as a dependency there will be cases where pHash gets disabled because scipy is not installed, not that scipy.fftpack is broken.

On a stylistic note, "if (havefftpack == False):" can be replaced by "if not havefftpack:" in line 128.

I Agree.

runarbu avatar Sep 09 '14 13:09 runarbu