Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue even if scipy.fftpack is missing #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

runarbu
Copy link

@runarbu runarbu commented Sep 9, 2014

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.

Try to import the scipy.fftpack module. If it is not available pHash
will not work, but one can still use aHash and dHash.
@JohannesBuchner
Copy link
Owner

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.

@runarbu
Copy link
Author

runarbu commented Sep 9, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants