DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
228 stars 50 forks source link

PyDIP: WienerDeconvolution not found on MacOS #139

Closed steveincolo closed 11 months ago

steveincolo commented 11 months ago

Component PyDIP, installed via 'pip install diplib'.

Describe the bug Cannot import WienerDeconvolution from diplib on MacOS. Other functions, such as BilateralFilter, UnsharpMask, and Gauss import successfully and are well-behaved.

To Reproduce At an interactive Python prompt or in a Jupyter notebook, enter 'from diplib import WienerDeconvolution'. The result:

DIPlib -- a quantitative image analysis library Version 3.1.0 (Sep 24 2021) For more information see https://diplib.org/

ImportError Traceback (most recent call last) Input In [1], in ----> 1 from diplib import WienerDeconvolution

ImportError: cannot import name 'WienerDeconvolution' from 'diplib' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/diplib/init.py)

On Windows 11 Pro (Version: 10.0.22621 Build 22621, Processor: AMD Ryzen 7 3750H) WienerDeconvolution imports successfully and is well-behaved.

System information: Reproduced on two systems.

crisluengo commented 11 months ago

The Python binding for this function was added in 3.4.0. You can update your DIPlib installation with pip install -U diplib.

I had to look though the git history to find out, apparently we forgot to add this function name to the change log for PyDIP: https://diplib.org/changelogs/diplib_3.4.0.html I'll update the change log.

steveincolo commented 11 months ago

Thanks! Unfortunately, on MacOS, 'pip install -U diplib' does not update to 3.4. If I do pip install diplib==3.4, I get

ERROR: Could not find a version that satisfies the requirement diplib==3.4 (from versions: 3.0b5, 3.0b6, 3.0b7, 3.0b8, 3.0.0, 3.1rc1, 3.1.0) ERROR: No matching distribution found for diplib==3.4

On Windows 11, I have what appears to be the latest, 3.4.1.

crisluengo commented 11 months ago

Are you using a very old version of Python maybe? The latest release, 3.4.1, is supported for Python versions 3.8 to 3.12.

steveincolo commented 11 months ago

Python 3.8 in both cases. Pip is up-to-date, version 23.3.2.

crisluengo commented 11 months ago

This is the installation file for Intel Macs: https://files.pythonhosted.org/packages/25/dc/fa20e4298c8750ec3c60ea283cd55cf75902604acb7bed08449160708648/diplib-3.4.1-cp38-cp38-macosx_12_0_x86_64.whl and for Apple Silicon Macs: https://files.pythonhosted.org/packages/2c/4e/8c1c5c07a3473a23bb574be4f72172fee7a8ea978d32970ed9404ee74916/diplib-3.4.1-cp38-cp38-macosx_12_0_arm64.whl

The files are there, you should be able to install them with pip. Maybe your pip is configured to search a different repository?

What do you see when you do

pip download -v -v "diplib"  | grep 'location(s) to search' -A5

I see this:

1 location(s) to search for versions of diplib:
* https://pypi.org/simple/diplib/
Fetching project page and analyzing links: https://pypi.org/simple/diplib/
Getting page https://pypi.org/simple/diplib/
Found index url https://pypi.org/simple/
Looking up "https://pypi.org/simple/diplib/" in the cache

In particular, you need to see "https://pypi.org". If you see a different URL there, then it's a repository that made copies a long time ago and hasn't updated. We push installation files only to pypi.org.

steveincolo commented 11 months ago

'pip download -v -v "diplib" | grep 'location(s) to search' -A5' gives this:

1 location(s) to search for versions of diplib: * https://pypi.org/simple/diplib/ Fetching project page and analyzing links: https://pypi.org/simple/diplib/ Getting page https://pypi.org/simple/diplib/ Found index url https://pypi.org/simple/ Looking up "https://pypi.org/simple/diplib/" in the cache

which appears to be identical. This is on Intel Mac (1.6 GHz Dual-Core Intel Core i5).

crisluengo commented 11 months ago

This is weird!

Can you download the wheel https://files.pythonhosted.org/packages/25/dc/fa20e4298c8750ec3c60ea283cd55cf75902604acb7bed08449160708648/diplib-3.4.1-cp38-cp38-macosx_12_0_x86_64.whl and then install it with pip install <filename.whl>?

crisluengo commented 11 months ago

Oh, are you on an old version of macOS? 3.1.0 was built for macOS 10.15 (Catalina), starting with 3.2.0 we built for macOS 11.0 (Big Sur), and 3.4.1 was built for macOS 12.0 (Monterey).

I guess the Intel version could be built for older OS versions, but I didn’t think people would be that far behind. With how strongly they push upgrades at Apple and all that.

Big Sur is no longer supported, Monterey is the oldest version Apple is still supporting.

steveincolo commented 11 months ago

Yes, I'm on Monterey 12.3.1. Nonetheless, when I try 'pip install diplib-3.4.1[...].whl', I get

ERROR: diplib-3.4.1-cp38-cp38-macosx_12_0_x86_64.whl is not a supported wheel on this platform.

The other user is on Catalina, so that explains his issue.

crisluengo commented 11 months ago

If you have Monterey and an Intel chip, that wheel should work for you. I cannot explain that error message.

For the older macOS machine, if you're unwilling to upgrade, you'd have to build DIPlib yourself. This is not hard, the most time-consuming part is having to install the build tools if you don't have them already. We have step-by-step instructions: https://diplib.org/diplib-docs/building_macos.html

steveincolo commented 11 months ago

Thanks! And thanks for diplib and PyDIP, a big performance improvement over scikit-image!